diff options
author | rfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f> | 2010-11-05 02:25:50 +0000 |
---|---|---|
committer | rfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f> | 2010-11-05 02:25:50 +0000 |
commit | 30fc0f278963f03f54a29b38b5f23f50ef7249b5 (patch) | |
tree | ae0c72ce5247e2749294608d851b0f20d600c814 /fs/wrapfs | |
parent | c5e46ddcb83fcbef7a9c14d03886e10d6275903e (diff) | |
download | pyfilesystem-git-30fc0f278963f03f54a29b38b5f23f50ef7249b5.tar.gz |
Add testcases for file.truncate(), and fix some failing FS implementations
Diffstat (limited to 'fs/wrapfs')
-rw-r--r-- | fs/wrapfs/limitsizefs.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/wrapfs/limitsizefs.py b/fs/wrapfs/limitsizefs.py index 6fa40fd..01616c6 100644 --- a/fs/wrapfs/limitsizefs.py +++ b/fs/wrapfs/limitsizefs.py @@ -61,7 +61,7 @@ class LimitSizeFS(WrapFS): self._file_sizes[path] = 0 return LimitSizeFile(self,path,f,mode,size) - def _ensure_file_size(self, path, size): + def _ensure_file_size(self, path, size, shrink=False): path = relpath(normpath(path)) with self._size_lock: if path not in self._file_sizes: @@ -73,6 +73,9 @@ class LimitSizeFS(WrapFS): raise StorageSpaceError("write") self.cur_size += diff self._file_sizes[path] = size + elif diff < 0 and shrink: + self.cur_size += diff + self._file_sizes[path] = size def copy(self, src, dst, **kwds): FS.copy(self,src,dst,**kwds) @@ -141,7 +144,7 @@ class LimitSizeFile(object): pos = self.file.tell() if size is None: size = pos - self.fs._ensure_file_size(self.path,size) + self.fs._ensure_file_size(self.path,size,shrink=True) self.file.truncate(size) self.size = size |