1. Benoit Boissinot
  2. django-storages

Commits

David Larlet  committed 7b34771

FTP: refs #4, makes exists() more reliable. Thanks Wim Leers.

  • Participants
  • Parent commits 912f387
  • Branches default

Comments (0)

Files changed (1)

File backends/FTPStorage.py

View file
  • Ignore whitespace
     def exists(self, name):
         self._start_connection()
         try:
-            if name in self._connection.nlst(os.path.dirname(name)):
+            if os.path.basename(name) in self._connection.nlst(os.path.dirname(name) + '/'):
                 return True
             else:
                 return False
         except ftplib.error_temp, e:
             return False
+        except ftplib.error_perm, e:
+            # error_perm: 550 Can't find file
+            return False
         except ftplib.all_errors, e:
             raise FTPStorageException('Error when testing existence of %s' % name)