ENHANCEMENT Filesystem::sync() now accepts a folderID argument, meaning you can specifically target a folder and it's children to sychronise, instead of everything (from r82840)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@89724 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2009-10-21 02:33:55 +00:00
parent 1e09bc4907
commit b85af0194e

View File

@ -102,9 +102,18 @@ class Filesystem extends Object {
/**
* This function ensures the file table is correct with the files in the assets folder.
*
* If a Folder record ID is given, all of that folder's children will be synchronised.
* If the given Folder ID isn't found, or not specified at all, then everything will
* be synchronised from the root folder (singleton Folder).
*
* @param int $folderID Folder ID to sync along with all it's children
*/
static function sync() {
$results = singleton('Folder')->syncChildren();
static function sync($folderID = null) {
$folder = DataObject::get_by_id('Folder', (int) $folderID);
if(!($folder && $folder->exists())) $folder = singleton('Folder');
$results = $folder->syncChildren();
$finished = false;
while(!$finished) {
$orphans = DB::query("SELECT \"C\".\"ID\" FROM \"File\" AS \"C\"