Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15423239
D16497.id39702.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D16497.id39702.diff
View Options
diff --git a/src/applications/files/management/PhabricatorFilesManagementMigrateWorkflow.php b/src/applications/files/management/PhabricatorFilesManagementMigrateWorkflow.php
--- a/src/applications/files/management/PhabricatorFilesManagementMigrateWorkflow.php
+++ b/src/applications/files/management/PhabricatorFilesManagementMigrateWorkflow.php
@@ -37,6 +37,12 @@
'help' => pht('Migrate all files.'),
),
array(
+ 'name' => 'copy',
+ 'help' => pht(
+ 'Copy file data instead of moving it: after migrating, do not '.
+ 'remove the old data even if it is no longer referenced.'),
+ ),
+ array(
'name' => 'names',
'wildcard' => true,
),
@@ -70,6 +76,8 @@
$min_size = (int)$args->getArg('min-size');
$max_size = (int)$args->getArg('max-size');
+ $is_copy = $args->getArg('copy');
+
$failed = array();
$engines = PhabricatorFileStorageEngine::loadAllEngines();
$total_bytes = 0;
@@ -158,7 +166,7 @@
if ($is_dry_run) {
// Do nothing, this is a dry run.
} else {
- $file->migrateToEngine($target_engine);
+ $file->migrateToEngine($target_engine, $is_copy);
}
$total_files += 1;
diff --git a/src/applications/files/storage/PhabricatorFile.php b/src/applications/files/storage/PhabricatorFile.php
--- a/src/applications/files/storage/PhabricatorFile.php
+++ b/src/applications/files/storage/PhabricatorFile.php
@@ -422,7 +422,10 @@
return self::buildFromFileData($data, $params);
}
- public function migrateToEngine(PhabricatorFileStorageEngine $engine) {
+ public function migrateToEngine(
+ PhabricatorFileStorageEngine $engine,
+ $make_copy) {
+
if (!$this->getID() || !$this->getStorageHandle()) {
throw new Exception(
pht("You can not migrate a file which hasn't yet been saved."));
@@ -446,10 +449,12 @@
$this->setStorageHandle($new_handle);
$this->save();
- $this->deleteFileDataIfUnused(
- $old_engine,
- $old_identifier,
- $old_handle);
+ if (!$make_copy) {
+ $this->deleteFileDataIfUnused(
+ $old_engine,
+ $old_identifier,
+ $old_handle);
+ }
return $this;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 23, 2:10 PM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7679409
Default Alt Text
D16497.id39702.diff (2 KB)
Attached To
Mode
D16497: Add a "--copy" flag to "bin/files migrate"
Attached
Detach File
Event Timeline
Log In to Comment