b2sdk.sync.policy – Policy

class b2sdk.sync.policy.AbstractFileSyncPolicy(source_file, source_folder, dest_file, dest_folder, now_millis, args)[source]

Bases: object

Abstract policy class

DESTINATION_PREFIX = NotImplemented
SOURCE_PREFIX = NotImplemented
__init__(source_file, source_folder, dest_file, dest_folder, now_millis, args)[source]
Parameters
classmethod files_are_different(source_file, dest_file, args)[source]

Compare two files and determine if the the destination file should be replaced by the source file.

Parameters
Return type

bool

get_all_actions()[source]

Yield file actions.

class b2sdk.sync.policy.DownAndDeletePolicy(source_file, source_folder, dest_file, dest_folder, now_millis, args)[source]

Bases: b2sdk.sync.policy.DownPolicy

File is synced down (from the cloud to disk) and the delete flag is SET

class b2sdk.sync.policy.DownAndKeepDaysPolicy(source_file, source_folder, dest_file, dest_folder, now_millis, args)[source]

Bases: b2sdk.sync.policy.DownPolicy

File is synced down (from the cloud to disk) and the keepDays flag is SET

class b2sdk.sync.policy.DownPolicy(source_file, source_folder, dest_file, dest_folder, now_millis, args)[source]

Bases: b2sdk.sync.policy.AbstractFileSyncPolicy

File is synced down (from the cloud to disk)

DESTINATION_PREFIX = 'local://'
SOURCE_PREFIX = 'b2://'
class b2sdk.sync.policy.UpAndDeletePolicy(source_file, source_folder, dest_file, dest_folder, now_millis, args)[source]

Bases: b2sdk.sync.policy.UpPolicy

File is synced up (from disk to the cloud) and the delete flag is SET

class b2sdk.sync.policy.UpAndKeepDaysPolicy(source_file, source_folder, dest_file, dest_folder, now_millis, args)[source]

Bases: b2sdk.sync.policy.UpPolicy

File is synced up (from disk to the cloud) and the keepDays flag is SET

class b2sdk.sync.policy.UpPolicy(source_file, source_folder, dest_file, dest_folder, now_millis, args)[source]

Bases: b2sdk.sync.policy.AbstractFileSyncPolicy

File is synced up (from disk the cloud)

DESTINATION_PREFIX = 'b2://'
SOURCE_PREFIX = 'local://'
b2sdk.sync.policy.make_b2_delete_actions(source_file, dest_file, dest_folder, transferred)[source]

Creates the actions to delete files stored on B2, which are not present locally.

Parameters
b2sdk.sync.policy.make_b2_delete_note(version, index, transferred)[source]

Create a note message for delete action

Parameters
  • version – an object which contains file version info

  • index (int) – file version index

  • transferred (bool) – if True, file has been transferred, False otherwise

b2sdk.sync.policy.make_b2_keep_days_actions(source_file, dest_file, dest_folder, transferred, keep_days, now_millis)[source]

Creates the actions to hide or delete existing versions of a file stored in b2.

When keepDays is set, all files that were visible any time from keepDays ago until now must be kept. If versions were uploaded 5 days ago, 15 days ago, and 25 days ago, and the keepDays is 10, only the 25-day old version can be deleted. The 15 day-old version was visible 10 days ago.

Parameters