Cscott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/165005

Change subject: Don't stop gc'ing if a file disappears.
......................................................................

Don't stop gc'ing if a file disappears.

When running two gc jobs simultaneously (for example, if one is manually
started and then the automatically-scheduled one in the service begins)
some files can 'disappear' before we have a chance to delete them.
Don't crash the gc thread if that happens, continue gc'ing the rest
of the files.

Change-Id: I426029244ccf5a173b2d822560d238221c1d8aa6
---
M lib/threads/gc.js
1 file changed, 7 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Collection/OfflineContentGenerator
 refs/changes/05/165005/1

diff --git a/lib/threads/gc.js b/lib/threads/gc.js
index fe86c54..938633d 100644
--- a/lib/threads/gc.js
+++ b/lib/threads/gc.js
@@ -181,7 +181,10 @@
                var count = 0, errors = [];
                if (!dir || !lifetime) { return; }
                var clean = function( dir, force ) {
-                       return readdir( dir ).map( function( file ) {
+                       return readdir( dir ).catch( function( error ) {
+                               // directory already removed?
+                               errors.push( dir );
+                       }).map( function( file ) {
                                var fullpath = path.join( dir, file );
                                return lstat( fullpath ).then(function( stat ) {
                                        // skip files/directories based on 
modification time
@@ -213,6 +216,9 @@
                                                        errors.push( fullpath );
                                                });
                                        }
+                               }, function(error) {
+                                       // error during stat -- file already 
gone?
+                                       errors.push( fullpath );
                                });
                        });
                };

-- 
To view, visit https://gerrit.wikimedia.org/r/165005
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I426029244ccf5a173b2d822560d238221c1d8aa6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Collection/OfflineContentGenerator
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to