def _async_autosave(self): # Because this method is called asynchronously, it's possible that, if unlucky, it happens # exactly as the user is commiting a change. In these cases, the autosaved file might be a # save of the data in a quite weird state. I think this risk is acceptable. The alternative # is to put locks everywhere, which would complexify the application. existing_names = [name for name in os.listdir(self.app.cache_path) if name.startswith('autosave')] existing_names.sort() timestamp = int(time.time()) autosave_name = 'autosave{0}.moneyguru'.format(timestamp) while autosave_name in existing_names: timestamp += 1 autosave_name = 'autosave{0}.moneyguru'.format(timestamp) self.save_to_xml(op.join(self.app.cache_path, autosave_name), autosave=True) if len(existing_names) >= AUTOSAVE_BUFFER_COUNT: io.remove(op.join(self.app.cache_path, existing_names[0]))
def getmatches(*args, **kw): io.remove(file2.path) return [Match(file1, file2, 100)]
def _do_delete(self, path): io.remove(path)