Index: trunk/phase3/includes/upload/UploadStash.php |
— | — | @@ -23,9 +23,6 @@ |
24 | 24 | // behind, throw an exception instead. (at what point is broken better than slow?) |
25 | 25 | const MAX_LAG = 30; |
26 | 26 | |
27 | | - // Age of the repository in hours. That is, after how long will files be assumed abandoned and deleted? |
28 | | - const REPO_AGE = 6; |
29 | | - |
30 | 27 | /** |
31 | 28 | * repository that this uses to store temp files |
32 | 29 | * public because we sometimes need to get a LocalFile within the same repo. |
— | — | @@ -69,6 +66,12 @@ |
70 | 67 | $this->userId = $this->user->getId(); |
71 | 68 | $this->isLoggedIn = $this->user->isLoggedIn(); |
72 | 69 | } |
| 70 | + |
| 71 | + // Age of the repository in seconds. That is, after how long will files be assumed abandoned and deleted? |
| 72 | + global $wgUploadStashMaxAge; |
| 73 | + if( $wgUploadStashMaxAge === null ) { |
| 74 | + $wgUploadStashMaxAge = 6 * 3600; // default: 6 hours. |
| 75 | + } |
73 | 76 | } |
74 | 77 | |
75 | 78 | /** |
— | — | @@ -263,10 +266,10 @@ |
264 | 267 | |
265 | 268 | // The current user can't have this key if: |
266 | 269 | // - the key is owned by someone else and |
267 | | - // - the age of the key is less than REPO_AGE |
| 270 | + // - the age of the key is less than $wgUploadStashMaxAge |
268 | 271 | if ( is_object( $row ) ) { |
269 | 272 | if ( $row->us_user != $this->userId && |
270 | | - $row->wfTimestamp( TS_UNIX, $row->us_timestamp ) > time() - UploadStash::REPO_AGE * 3600 |
| 273 | + $row->wfTimestamp( TS_UNIX, $row->us_timestamp ) > time() - $wgUploadStashMaxAge |
271 | 274 | ) { |
272 | 275 | $dbw->rollback(); |
273 | 276 | throw new UploadStashWrongOwnerException( "Attempting to upload a duplicate of a file that someone else has stashed" ); |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -180,6 +180,11 @@ |
181 | 181 | $wgUploadPath = false; |
182 | 182 | |
183 | 183 | /** |
| 184 | + * The maximum age of temporary (incomplete) uploaded files |
| 185 | + */ |
| 186 | +$wgUploadStashMaxAge = 6 * 3600; // 6 hours |
| 187 | + |
| 188 | +/** |
184 | 189 | * The filesystem path of the images directory. Defaults to "{$IP}/images". |
185 | 190 | */ |
186 | 191 | $wgUploadDirectory = false; |
Index: trunk/phase3/maintenance/cleanupUploadStash.php |
— | — | @@ -38,12 +38,18 @@ |
39 | 39 | $repo = RepoGroup::singleton()->getLocalRepo(); |
40 | 40 | |
41 | 41 | $dbr = $repo->getSlaveDb(); |
| 42 | + |
| 43 | + // how far back should this look for files to delete? |
| 44 | + global $wgUploadStashMaxAge; |
| 45 | + if( $wgUploadStashMaxAge === null ) { |
| 46 | + $wgUploadStashMaxAge = 6 * 3600; // default: 6 hours. |
| 47 | + } |
42 | 48 | |
43 | 49 | $this->output( "Getting list of files to clean up...\n" ); |
44 | 50 | $res = $dbr->select( |
45 | 51 | 'uploadstash', |
46 | 52 | 'us_key', |
47 | | - 'us_timestamp < ' . $dbr->timestamp( time() - UploadStash::REPO_AGE * 3600 ), |
| 53 | + 'us_timestamp < ' . $dbr->timestamp( time() - $wgUploadStashMaxAge ), |
48 | 54 | __METHOD__ |
49 | 55 | ); |
50 | 56 | |