Mercurial > libervia-backend
changeset 1607:4741e2f5eed2
plugin file: progressFinished and progressError are now sent on SatFile.close. eof Deferred attribute is removed, as it is not used and bring unnecessary complication
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 16 Nov 2015 00:24:49 +0100 |
parents | de785fcf9a7b |
children | 05274b27e90e |
files | src/plugins/plugin_misc_file.py |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/plugin_misc_file.py Sun Nov 15 23:42:21 2015 +0100 +++ b/src/plugins/plugin_misc_file.py Mon Nov 16 00:24:49 2015 +0100 @@ -68,14 +68,16 @@ self._file = open(path, mode) self.size = size self.profile = profile - self.eof = defer.Deferred() self.host.registerProgressCb(self.uid, self.getProgress, profile) self.host.bridge.progressStarted(self.uid, self.profile) - self.eof.addCallback(lambda ignore: self.host.bridge.progressFinished(self.uid, self.profile)) - self.eof.addErrback(lambda failure: self.host.bridge.progressError(self.uid, unicode(failure), self.profile)) def close(self): + position = self._file.tell() self._file.close() + if not self.size or self.size == position: + self.host.bridge.progressFinished(self.uid, self.profile) + else: + self.host.bridge.progressError(self.uid, u"size doesn't match", self.profile) self.host.removeProgressCb(self.uid, self.profile) def flush(self): @@ -86,8 +88,6 @@ def read(self, size=-1): read = self._file.read(size) - if not read: - self.eof.callback(None) return read def seek(self, offset, whence=os.SEEK_SET):