mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-21 13:57:51 +00:00
Fix some pyflakes errors and warnings.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
f423e72062
commit
2bd93d2e02
@ -199,7 +199,6 @@ class MagicFolder(service.MultiService):
|
|||||||
|
|
||||||
def _filter_scan_batch(self, result):
|
def _filter_scan_batch(self, result):
|
||||||
extension = []
|
extension = []
|
||||||
max_version_dict = {}
|
|
||||||
for name in self._download_scan_batch.keys():
|
for name in self._download_scan_batch.keys():
|
||||||
if name in self._download_pending:
|
if name in self._download_pending:
|
||||||
continue
|
continue
|
||||||
@ -246,44 +245,58 @@ class MagicFolder(service.MultiService):
|
|||||||
except FilenameEncodingError:
|
except FilenameEncodingError:
|
||||||
raise(Exception("WARNING: magic folder: could not list directory %s due to a filename encoding error" % (quoted_path,)))
|
raise(Exception("WARNING: magic folder: could not list directory %s due to a filename encoding error" % (quoted_path,)))
|
||||||
|
|
||||||
|
d = defer.succeed(None)
|
||||||
for child in children:
|
for child in children:
|
||||||
assert isinstance(child, unicode), child
|
assert isinstance(child, unicode), child
|
||||||
childpath = os.path.join(localpath, child)
|
childpath = os.path.join(localpath, child)
|
||||||
# note: symlinks to directories are both islink() and isdir()
|
|
||||||
isdir = os.path.isdir(childpath)
|
|
||||||
isfile = os.path.isfile(childpath)
|
|
||||||
islink = os.path.islink(childpath)
|
|
||||||
|
|
||||||
if islink:
|
def _process_child(ign, childpath=childpath):
|
||||||
self.warn("WARNING: cannot backup symlink %s" % quote_local_unicode_path(childpath))
|
# note: symlinks to directories are both islink() and isdir()
|
||||||
elif isdir:
|
isdir = os.path.isdir(childpath)
|
||||||
# process directories unconditionally
|
isfile = os.path.isfile(childpath)
|
||||||
self._append_to_upload_deque(childpath)
|
islink = os.path.islink(childpath)
|
||||||
|
|
||||||
# recurse on the child directory
|
if islink:
|
||||||
self._scan(childpath)
|
self.warn("WARNING: cannot backup symlink %s" % quote_local_unicode_path(childpath))
|
||||||
elif isfile:
|
return None
|
||||||
file_version = self._db.get_local_file_version(childpath)
|
elif isdir:
|
||||||
if file_version is None:
|
# process directories unconditionally
|
||||||
# XXX upload if we didn't record our version in magicfolder db?
|
|
||||||
self._append_to_upload_deque(childpath)
|
self._append_to_upload_deque(childpath)
|
||||||
else:
|
|
||||||
file_node, metadata = self._get_collective_latest_file(childpath)
|
# recurse on the child directory
|
||||||
if collective_version is None:
|
return self._scan(childpath)
|
||||||
continue
|
elif isfile:
|
||||||
if file_version > collective_version:
|
file_version = self._db.get_local_file_version(childpath)
|
||||||
|
if file_version is None:
|
||||||
|
# XXX upload if we didn't record our version in magicfolder db?
|
||||||
self._append_to_upload_deque(childpath)
|
self._append_to_upload_deque(childpath)
|
||||||
elif file_version < collective_version:
|
return None
|
||||||
# if a collective version of the file is newer than ours
|
|
||||||
# we must download it and unlink the old file from our upload dirnode
|
|
||||||
self._append_to_download_deque(childpath)
|
|
||||||
# XXX where should we save the returned deferred?
|
|
||||||
d = self._upload_dirnode.delete(childpath, must_be_file=True)
|
|
||||||
else:
|
else:
|
||||||
# XXX same version. do nothing.
|
d2 = self._get_collective_latest_file(childpath)
|
||||||
pass
|
def _got_latest_file((file_node, metadata)):
|
||||||
else:
|
collective_version = metadata['version']
|
||||||
self.warn("WARNING: cannot backup special file %s" % quote_local_unicode_path(childpath))
|
if collective_version is None:
|
||||||
|
return None
|
||||||
|
if file_version > collective_version:
|
||||||
|
self._append_to_upload_deque(childpath)
|
||||||
|
elif file_version < collective_version:
|
||||||
|
# if a collective version of the file is newer than ours
|
||||||
|
# we must download it and unlink the old file from our upload dirnode
|
||||||
|
self._append_to_download_deque(childpath)
|
||||||
|
# XXX where should we save the returned deferred?
|
||||||
|
return self._upload_dirnode.delete(childpath, must_be_file=True)
|
||||||
|
else:
|
||||||
|
# XXX same version. do nothing.
|
||||||
|
pass
|
||||||
|
d2.addCallback(_got_latest_file)
|
||||||
|
return d2
|
||||||
|
else:
|
||||||
|
self.warn("WARNING: cannot backup special file %s" % quote_local_unicode_path(childpath))
|
||||||
|
return None
|
||||||
|
d.addCallback(_process_child)
|
||||||
|
d.addErrback(log.err)
|
||||||
|
|
||||||
|
return d
|
||||||
|
|
||||||
def startService(self):
|
def startService(self):
|
||||||
self._db = backupdb.get_backupdb(self._dbfile, create_version=(backupdb.SCHEMA_v3, 3))
|
self._db = backupdb.get_backupdb(self._dbfile, create_version=(backupdb.SCHEMA_v3, 3))
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
import os, json
|
import os
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
from twisted.python import usage
|
from twisted.python import usage
|
||||||
|
|
||||||
from .common import BaseOptions, BasedirOptions, get_aliases
|
from .common import BaseOptions, BasedirOptions, get_aliases
|
||||||
from .cli import MakeDirectoryOptions, ListOptions, LnOptions
|
from .cli import MakeDirectoryOptions, LnOptions
|
||||||
import tahoe_ls, tahoe_mv
|
import tahoe_mv
|
||||||
from allmydata.util import fileutil
|
from allmydata.util import fileutil
|
||||||
from allmydata import uri
|
from allmydata import uri
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
import json
|
|
||||||
|
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
Loading…
Reference in New Issue
Block a user