@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a "--copy" flag to "bin/files migrate"

Summary:
Ref T11596. When exporting data from the Phacility cluster, we `bin/files migrate` data from S3 into a database dump on the `aux` tier.

With current semantics, this //moves// the data and destroys it in S3.

Add a `--copy` flag to //copy// the data instead. This leaves the old copy around, which is what we want for exports.

Test Plan:
- Ran `bin/files migrate` to go from `blob` to `disk` with `--copy`. Verified a copy was left in the database.
- Copied it back, verified a copy was left on disk (total: 2 database copies, 1 disk copy).
- Moved it back without copy, verified database was destroyed and disk was created (total: 1 database copy, 2 disk copies).
- Moved it back without copy, verified local disk was destroyed and blob was created (total: 2 datbabase copies, 1 disk copy).

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11596

Differential Revision: https://secure.phabricator.com/D16497

+19 -6
+9 -1
src/applications/files/management/PhabricatorFilesManagementMigrateWorkflow.php
··· 37 37 'help' => pht('Migrate all files.'), 38 38 ), 39 39 array( 40 + 'name' => 'copy', 41 + 'help' => pht( 42 + 'Copy file data instead of moving it: after migrating, do not '. 43 + 'remove the old data even if it is no longer referenced.'), 44 + ), 45 + array( 40 46 'name' => 'names', 41 47 'wildcard' => true, 42 48 ), ··· 69 75 70 76 $min_size = (int)$args->getArg('min-size'); 71 77 $max_size = (int)$args->getArg('max-size'); 78 + 79 + $is_copy = $args->getArg('copy'); 72 80 73 81 $failed = array(); 74 82 $engines = PhabricatorFileStorageEngine::loadAllEngines(); ··· 158 166 if ($is_dry_run) { 159 167 // Do nothing, this is a dry run. 160 168 } else { 161 - $file->migrateToEngine($target_engine); 169 + $file->migrateToEngine($target_engine, $is_copy); 162 170 } 163 171 164 172 $total_files += 1;
+10 -5
src/applications/files/storage/PhabricatorFile.php
··· 422 422 return self::buildFromFileData($data, $params); 423 423 } 424 424 425 - public function migrateToEngine(PhabricatorFileStorageEngine $engine) { 425 + public function migrateToEngine( 426 + PhabricatorFileStorageEngine $engine, 427 + $make_copy) { 428 + 426 429 if (!$this->getID() || !$this->getStorageHandle()) { 427 430 throw new Exception( 428 431 pht("You can not migrate a file which hasn't yet been saved.")); ··· 446 449 $this->setStorageHandle($new_handle); 447 450 $this->save(); 448 451 449 - $this->deleteFileDataIfUnused( 450 - $old_engine, 451 - $old_identifier, 452 - $old_handle); 452 + if (!$make_copy) { 453 + $this->deleteFileDataIfUnused( 454 + $old_engine, 455 + $old_identifier, 456 + $old_handle); 457 + } 453 458 454 459 return $this; 455 460 }