diff --git a/swift/obj/updater.py b/swift/obj/updater.py index 1962d66..7182380 100644 --- a/swift/obj/updater.py +++ b/swift/obj/updater.py @@ -55,6 +55,7 @@ class ObjectUpdater(Daemon): self.recon_cache_path = conf.get('recon_cache_path', '/var/cache/swift') self.rcache = os.path.join(self.recon_cache_path, 'object.recon') + self.reclaim_age = int(conf.get('reclaim_age', 86400 * 7)) def _listdir(self, path): try: @@ -175,6 +176,7 @@ class ObjectUpdater(Daemon): continue try: obj_hash, timestamp = update.split('-') + timestamp = Timestamp(timestamp).external except ValueError: self.logger.increment('errors') self.logger.error( @@ -182,7 +184,15 @@ class ObjectUpdater(Daemon): 'name %s') % (update_path)) continue - if obj_hash == last_obj_hash: + reclaim_date = time.time() - self.reclaim_age + if obj_hash == last_obj_hash or timestamp > reclaim_date: + if timestamp > reclaim_date: + self.logger.info( + _('Unlinking old async pending file %s') + % (update_path)) + self.logger.increment("unlinks") + os.unlink(update_path) + elif timestamp > time.time() - self.reclaim_age: self.logger.increment("unlinks") os.unlink(update_path) else: