Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ENHANCEMENT Allow disabling of File::updateFilesystem() which is useful

for manually managing the filesystem paths instead. Defaults to on, but
useful to turn off when loading File records in a YAML fixture for test
data.
  • Loading branch information...
commit 7f60ced66be1037f3b579644205ef95c0b4db55c 1 parent f8d38a3
@halkyon halkyon authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 filesystem/File.php
View
7 filesystem/File.php
@@ -149,7 +149,8 @@ class File extends DataObject {
*/
public static $apply_restrictions_to_admin = true;
-
+ public static $update_filesystem = true;
+
/**
* Cached result of a "SHOW FIELDS" call
* in instance_get() for performance reasons.
@@ -476,6 +477,8 @@ protected function onAfterWrite() {
* (it might have been influenced by {@link setName()} or {@link setParentID()} before).
*/
public function updateFilesystem() {
+ if(!self::$update_filesystem) return false;
+
// Regenerate "Filename", just to be sure
$this->setField('Filename', $this->getRelativePath());
@@ -511,7 +514,7 @@ public function updateFilesystem() {
// Only check if we're dealing with a file, otherwise the folder will need to be created
if(!file_exists(dirname($pathAfterAbs))) throw new Exception("Cannot move $pathBefore to $pathAfter - Directory " . dirname($pathAfter) . " doesn't exist");
}
-
+
// Rename file or folder
$success = rename($pathBeforeAbs, $pathAfterAbs);
if(!$success) throw new Exception("Cannot move $pathBeforeAbs to $pathAfterAbs");
Please sign in to comment.
Something went wrong with that request. Please try again.