Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
raise InvalidArgument('compare_threshold', 'must be a positive integer')
if self.newer_file_mode not in tuple(NewerFileSyncMode):
raise InvalidArgument(
'newer_file_mode',
'must be one of :%s' % NewerFileSyncMode.__members__,
)
if self.keep_days_or_delete not in tuple(KeepOrDeleteMode):
raise InvalidArgument(
'keep_days_or_delete',
'must be one of :%s' % KeepOrDeleteMode.__members__,
)
if self.keep_days_or_delete == KeepOrDeleteMode.KEEP_BEFORE_DELETE and self.keep_days is None:
raise InvalidArgument(
'keep_days',
'is required when keep_days_or_delete is %s' % KeepOrDeleteMode.KEEP_BEFORE_DELETE,
)
if self.compare_version_mode not in tuple(CompareVersionMode):
raise InvalidArgument(
'compare_version_mode',
'must be one of :%s' % CompareVersionMode.__members__,
)
reporter,
policies_manager=DEFAULT_SCAN_MANAGER,
):
"""
Yield a sequence of actions that will sync the destination
folder to the source folder.
:param b2sdk.v1.AbstractFolder source_folder: source folder object
:param b2sdk.v1.AbstractFolder dest_folder: destination folder object
:param int now_millis: current time in milliseconds
:param b2sdk.v1.SyncReport reporter: reporter object
:param policies_manager: policies manager object
"""
if self.keep_days_or_delete == KeepOrDeleteMode.KEEP_BEFORE_DELETE and dest_folder.folder_type(
) == 'local':
raise InvalidArgument('keep_days_or_delete', 'cannot be used for local files')
source_type = source_folder.folder_type()
dest_type = dest_folder.folder_type()
sync_type = '%s-to-%s' % (source_type, dest_type)
if (source_type, dest_type) not in [('b2', 'local'), ('local', 'b2')]:
raise NotImplementedError("Sync support only local-to-b2 and b2-to-local")
for source_file, dest_file in zip_folders(
source_folder,
dest_folder,
reporter,
policies_manager,
):
if source_file is None:
logger.debug('determined that %s is not present on source', dest_file)
elif dest_file is None:
def _validate(self):
if self.compare_threshold < 0:
raise InvalidArgument('compare_threshold', 'must be a positive integer')
if self.newer_file_mode not in tuple(NewerFileSyncMode):
raise InvalidArgument(
'newer_file_mode',
'must be one of :%s' % NewerFileSyncMode.__members__,
)
if self.keep_days_or_delete not in tuple(KeepOrDeleteMode):
raise InvalidArgument(
'keep_days_or_delete',
'must be one of :%s' % KeepOrDeleteMode.__members__,
)
if self.keep_days_or_delete == KeepOrDeleteMode.KEEP_BEFORE_DELETE and self.keep_days is None:
raise InvalidArgument(
'keep_days',
'is required when keep_days_or_delete is %s' % KeepOrDeleteMode.KEEP_BEFORE_DELETE,
)
compare_threshold_exceeded = diff_size > compare_threshold
logger.debug(
'File %s: source size %s, dest size %s, diff %s, threshold %s, diff > threshold %s',
source_file.name,
source_size,
dest_size,
diff_size,
compare_threshold,
compare_threshold_exceeded,
)
# Replace if size difference is over threshold
return compare_threshold_exceeded
else:
raise InvalidArgument('compare_version_mode', 'is invalid option')
def _validate(self):
if self.compare_threshold < 0:
raise InvalidArgument('compare_threshold', 'must be a positive integer')
if self.newer_file_mode not in tuple(NewerFileSyncMode):
raise InvalidArgument(
'newer_file_mode',
'must be one of :%s' % NewerFileSyncMode.__members__,
)
if self.keep_days_or_delete not in tuple(KeepOrDeleteMode):
raise InvalidArgument(
'keep_days_or_delete',
'must be one of :%s' % KeepOrDeleteMode.__members__,
)
if self.keep_days_or_delete == KeepOrDeleteMode.KEEP_BEFORE_DELETE and self.keep_days is None:
raise InvalidArgument(
'keep_days',
'is required when keep_days_or_delete is %s' % KeepOrDeleteMode.KEEP_BEFORE_DELETE,
)
if self.compare_version_mode not in tuple(CompareVersionMode):
raise InvalidArgument(
'compare_version_mode',
'must be one of :%s' % CompareVersionMode.__members__,
)
def _validate(self):
if self.compare_threshold < 0:
raise InvalidArgument('compare_threshold', 'must be a positive integer')
if self.newer_file_mode not in tuple(NewerFileSyncMode):
raise InvalidArgument(
'newer_file_mode',
'must be one of :%s' % NewerFileSyncMode.__members__,
)
if self.keep_days_or_delete not in tuple(KeepOrDeleteMode):
raise InvalidArgument(
'keep_days_or_delete',
'must be one of :%s' % KeepOrDeleteMode.__members__,
)
if self.keep_days_or_delete == KeepOrDeleteMode.KEEP_BEFORE_DELETE and self.keep_days is None:
raise InvalidArgument(
'keep_days',
)
if self.keep_days_or_delete not in tuple(KeepOrDeleteMode):
raise InvalidArgument(
'keep_days_or_delete',
'must be one of :%s' % KeepOrDeleteMode.__members__,
)
if self.keep_days_or_delete == KeepOrDeleteMode.KEEP_BEFORE_DELETE and self.keep_days is None:
raise InvalidArgument(
'keep_days',
'is required when keep_days_or_delete is %s' % KeepOrDeleteMode.KEEP_BEFORE_DELETE,
)
if self.compare_version_mode not in tuple(CompareVersionMode):
raise InvalidArgument(
'compare_version_mode',
'must be one of :%s' % CompareVersionMode.__members__,
)