summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwillmcgugan@gmail.com <willmcgugan@gmail.com@67cdc799-7952-0410-af00-57a81ceafa0f>2013-09-10 00:10:53 +0000
committerwillmcgugan@gmail.com <willmcgugan@gmail.com@67cdc799-7952-0410-af00-57a81ceafa0f>2013-09-10 00:10:53 +0000
commit9274820511013c48b45a6654f76c5360f72f3551 (patch)
tree237459ba963840f65f1eb873c090245f86d6de14
parentfbe1238c34ef238a0a50166d6b2ec19a7ee94435 (diff)
downloadpyfilesystem-9274820511013c48b45a6654f76c5360f72f3551.tar.gz
createfile fixes
git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@876 67cdc799-7952-0410-af00-57a81ceafa0f
-rw-r--r--fs/base.py18
-rw-r--r--fs/path.py2
-rw-r--r--fs/remote.py1
-rw-r--r--fs/tests/test_remote.py3
4 files changed, 15 insertions, 9 deletions
diff --git a/fs/base.py b/fs/base.py
index c1c363d..8e2686e 100644
--- a/fs/base.py
+++ b/fs/base.py
@@ -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.
diff --git a/fs/path.py b/fs/path.py
index 31bb4c3..67aa481 100644
--- a/fs/path.py
+++ b/fs/path.py
@@ -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)