# HG changeset patch # User Goffi # Date 1447629889 -3600 # Node ID 4741e2f5eed271d1499be9b17491c750332b1b0a # Parent de785fcf9a7b0f8a23ec1b533cce4e06cc9ac134 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 diff -r de785fcf9a7b -r 4741e2f5eed2 src/plugins/plugin_misc_file.py --- 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):