delete upload memory file file on shutdown if upload queue is empty

master
Kevin Froman 2020-01-03 04:14:04 -06:00
parent ee7b68c844
commit d7be2ca16d
1 changed files with 8 additions and 2 deletions

View File

@ -59,5 +59,11 @@ class UploadQueue:
def save(self): def save(self):
"""Save to disk on shutdown or if called manually.""" """Save to disk on shutdown or if called manually."""
bl: deadsimplekv.DeadSimpleKV = self.communicator.blocksToUpload bl: deadsimplekv.DeadSimpleKV = self.communicator.blocksToUpload
if len(bl) == 0:
try:
os.remove(UPLOAD_MEMORY_FILE)
except FileNotFoundError:
pass
else:
self.store_obj.put('uploads', bl) self.store_obj.put('uploads', bl)
self.store_obj.flush() self.store_obj.flush()