diff options
author | willmcgugan@gmail.com <willmcgugan@gmail.com@67cdc799-7952-0410-af00-57a81ceafa0f> | 2013-09-10 00:10:53 +0000 |
---|---|---|
committer | willmcgugan@gmail.com <willmcgugan@gmail.com@67cdc799-7952-0410-af00-57a81ceafa0f> | 2013-09-10 00:10:53 +0000 |
commit | 6829f99a92430084a11f12645fe178ec20d25e16 (patch) | |
tree | 237459ba963840f65f1eb873c090245f86d6de14 | |
parent | cbcad9d0a1d2ca4101cff9ef5d6d6d9b66dcced7 (diff) | |
download | pyfilesystem-git-6829f99a92430084a11f12645fe178ec20d25e16.tar.gz |
createfile fixes
-rw-r--r-- | fs/base.py | 18 | ||||
-rw-r--r-- | fs/path.py | 2 | ||||
-rw-r--r-- | fs/remote.py | 1 | ||||
-rw-r--r-- | fs/tests/test_remote.py | 3 |
4 files changed, 15 insertions, 9 deletions
@@ -895,15 +895,15 @@ class FS(object): :param wipe: if True, the contents of the file will be erased """ - if not wipe and self.isfile(path): - return - - f = None - try: - f = self.open(path, 'w') - finally: - if f is not None: - f.close() + with self._lock: + if not wipe and self.isfile(path): + return + f = None + try: + f = self.open(path, 'wb') + finally: + if f is not None: + f.close() def opendir(self, path): """Opens a directory and returns a FS object representing its contents. @@ -192,6 +192,8 @@ def pathcombine(path1, path2): 'foo/bar/baz' """ + if not path1: + return path2.lstrip() return "%s/%s" % (path1.rstrip('/'), path2.lstrip('/')) diff --git a/fs/remote.py b/fs/remote.py index 1ac502b..86829c9 100644 --- a/fs/remote.py +++ b/fs/remote.py @@ -103,6 +103,7 @@ class RemoteFileBuffer(FileWrapper): # Do not use remote file object self._eof = True self._rfile = None + self._changed = True if rfile is not None and hasattr(rfile,"close"): rfile.close() super(RemoteFileBuffer,self).__init__(wrapped_file,mode) diff --git a/fs/tests/test_remote.py b/fs/tests/test_remote.py index 9a4db5e..4a21e3f 100644 --- a/fs/tests/test_remote.py +++ b/fs/tests/test_remote.py @@ -30,6 +30,9 @@ class RemoteTempFS(TempFS): Simple filesystem implementing setfilecontents for RemoteFileBuffer tests """ + def __repr__(self): + return '<RemoteTempFS: %s>' % self._temp_dir + def open(self, path, mode='rb', write_on_flush=True, **kwargs): if 'a' in mode or 'r' in mode or '+' in mode: f = super(RemoteTempFS, self).open(path, mode='rb', **kwargs) |