b2sdk._internal.sync.policy
- class b2sdk._internal.sync.policy.NewerFileSyncMode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Mode of handling files newer on destination than on source
- SKIP = 101
skip syncing such file
- REPLACE = 102
replace the file on the destination with the (older) file on source
- RAISE_ERROR = 103
raise a non-transient error, failing the sync operation
- class b2sdk._internal.sync.policy.CompareVersionMode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Mode of comparing versions of files to determine what should be synced and what shouldn’t
- MODTIME = 201
use file modification time on source filesystem
- SIZE = 202
compare using file size
- NONE = 203
compare using file name only
- class b2sdk._internal.sync.policy.AbstractFileSyncPolicy(source_path, source_folder, dest_path, dest_folder, now_millis, keep_days, newer_file_mode, compare_threshold, compare_version_mode=CompareVersionMode.MODTIME, encryption_settings_provider=<b2sdk._internal.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>, upload_mode=UploadMode.FULL, absolute_minimum_part_size=None)[source]
Bases:
object
Abstract policy class.
- Parameters:
source_path (
Optional
[AbstractPath
]) –source_folder (
AbstractFolder
) –dest_path (
Optional
[AbstractPath
]) –dest_folder (
AbstractFolder
) –now_millis (
int
) –keep_days (
int
) –newer_file_mode (
NewerFileSyncMode
) –compare_threshold (
int
) –compare_version_mode (
CompareVersionMode
) –encryption_settings_provider (
AbstractSyncEncryptionSettingsProvider
) –upload_mode (
UploadMode
) –
- DESTINATION_PREFIX = NotImplemented
- SOURCE_PREFIX = NotImplemented
- __init__(source_path, source_folder, dest_path, dest_folder, now_millis, keep_days, newer_file_mode, compare_threshold, compare_version_mode=CompareVersionMode.MODTIME, encryption_settings_provider=<b2sdk._internal.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>, upload_mode=UploadMode.FULL, absolute_minimum_part_size=None)[source]
- Parameters:
source_path (
Optional
[AbstractPath
]) – source file objectsource_folder (
AbstractFolder
) – source folder objectdest_path (
Optional
[AbstractPath
]) – destination file objectdest_folder (
AbstractFolder
) – destination folder objectnow_millis (
int
) – current time in millisecondskeep_days (
int
) – days to keep before deletenewer_file_mode (
NewerFileSyncMode
) – setting which determines handling for destination files newer than on the sourcecompare_threshold (
int
) – when comparing with size or time for synccompare_version_mode (
CompareVersionMode
) – how to compare source and destination filesencryption_settings_provider (
AbstractSyncEncryptionSettingsProvider
) – encryption setting providerupload_mode (
UploadMode
) – file upload modeabsolute_minimum_part_size (
Optional
[int
]) – minimum file part size that can be uploaded to the server
- classmethod files_are_different(source_path, dest_path, compare_threshold=None, compare_version_mode=CompareVersionMode.MODTIME, newer_file_mode=NewerFileSyncMode.RAISE_ERROR)[source]
Compare two files and determine if the the destination file should be replaced by the source file.
- Parameters:
source_path (
AbstractPath
) – source file objectdest_path (
AbstractPath
) – destination file objectcompare_threshold (
Optional
[int
]) – compare threshold when comparing by time or sizecompare_version_mode (
CompareVersionMode
) – source file version comparator methodnewer_file_mode (
NewerFileSyncMode
) – newer destination handling methodsource_path –
dest_path –
compare_threshold –
compare_version_mode –
newer_file_mode –
- class b2sdk._internal.sync.policy.DownPolicy(source_path, source_folder, dest_path, dest_folder, now_millis, keep_days, newer_file_mode, compare_threshold, compare_version_mode=CompareVersionMode.MODTIME, encryption_settings_provider=<b2sdk._internal.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>, upload_mode=UploadMode.FULL, absolute_minimum_part_size=None)[source]
Bases:
AbstractFileSyncPolicy
File is synced down (from the cloud to disk).
- Parameters:
source_path (
Optional
[AbstractPath
]) –source_folder (
AbstractFolder
) –dest_path (
Optional
[AbstractPath
]) –dest_folder (
AbstractFolder
) –now_millis (
int
) –keep_days (
int
) –newer_file_mode (
NewerFileSyncMode
) –compare_threshold (
int
) –compare_version_mode (
CompareVersionMode
) –encryption_settings_provider (
AbstractSyncEncryptionSettingsProvider
) –upload_mode (
UploadMode
) –
- DESTINATION_PREFIX = 'local://'
- SOURCE_PREFIX = 'b2://'
- class b2sdk._internal.sync.policy.UpPolicy(source_path, source_folder, dest_path, dest_folder, now_millis, keep_days, newer_file_mode, compare_threshold, compare_version_mode=CompareVersionMode.MODTIME, encryption_settings_provider=<b2sdk._internal.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>, upload_mode=UploadMode.FULL, absolute_minimum_part_size=None)[source]
Bases:
AbstractFileSyncPolicy
File is synced up (from disk the cloud).
- Parameters:
source_path (
Optional
[AbstractPath
]) –source_folder (
AbstractFolder
) –dest_path (
Optional
[AbstractPath
]) –dest_folder (
AbstractFolder
) –now_millis (
int
) –keep_days (
int
) –newer_file_mode (
NewerFileSyncMode
) –compare_threshold (
int
) –compare_version_mode (
CompareVersionMode
) –encryption_settings_provider (
AbstractSyncEncryptionSettingsProvider
) –upload_mode (
UploadMode
) –
- DESTINATION_PREFIX = 'b2://'
- SOURCE_PREFIX = 'local://'
- class b2sdk._internal.sync.policy.UpAndDeletePolicy(source_path, source_folder, dest_path, dest_folder, now_millis, keep_days, newer_file_mode, compare_threshold, compare_version_mode=CompareVersionMode.MODTIME, encryption_settings_provider=<b2sdk._internal.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>, upload_mode=UploadMode.FULL, absolute_minimum_part_size=None)[source]
Bases:
UpPolicy
File is synced up (from disk to the cloud) and the delete flag is SET.
- Parameters:
source_path (
Optional
[AbstractPath
]) –source_folder (
AbstractFolder
) –dest_path (
Optional
[AbstractPath
]) –dest_folder (
AbstractFolder
) –now_millis (
int
) –keep_days (
int
) –newer_file_mode (
NewerFileSyncMode
) –compare_threshold (
int
) –compare_version_mode (
CompareVersionMode
) –encryption_settings_provider (
AbstractSyncEncryptionSettingsProvider
) –upload_mode (
UploadMode
) –
- class b2sdk._internal.sync.policy.UpAndKeepDaysPolicy(source_path, source_folder, dest_path, dest_folder, now_millis, keep_days, newer_file_mode, compare_threshold, compare_version_mode=CompareVersionMode.MODTIME, encryption_settings_provider=<b2sdk._internal.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>, upload_mode=UploadMode.FULL, absolute_minimum_part_size=None)[source]
Bases:
UpPolicy
File is synced up (from disk to the cloud) and the keepDays flag is SET.
- Parameters:
source_path (
Optional
[AbstractPath
]) –source_folder (
AbstractFolder
) –dest_path (
Optional
[AbstractPath
]) –dest_folder (
AbstractFolder
) –now_millis (
int
) –keep_days (
int
) –newer_file_mode (
NewerFileSyncMode
) –compare_threshold (
int
) –compare_version_mode (
CompareVersionMode
) –encryption_settings_provider (
AbstractSyncEncryptionSettingsProvider
) –upload_mode (
UploadMode
) –
- class b2sdk._internal.sync.policy.DownAndDeletePolicy(source_path, source_folder, dest_path, dest_folder, now_millis, keep_days, newer_file_mode, compare_threshold, compare_version_mode=CompareVersionMode.MODTIME, encryption_settings_provider=<b2sdk._internal.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>, upload_mode=UploadMode.FULL, absolute_minimum_part_size=None)[source]
Bases:
DownPolicy
File is synced down (from the cloud to disk) and the delete flag is SET.
- Parameters:
source_path (
Optional
[AbstractPath
]) –source_folder (
AbstractFolder
) –dest_path (
Optional
[AbstractPath
]) –dest_folder (
AbstractFolder
) –now_millis (
int
) –keep_days (
int
) –newer_file_mode (
NewerFileSyncMode
) –compare_threshold (
int
) –compare_version_mode (
CompareVersionMode
) –encryption_settings_provider (
AbstractSyncEncryptionSettingsProvider
) –upload_mode (
UploadMode
) –
- class b2sdk._internal.sync.policy.DownAndKeepDaysPolicy(source_path, source_folder, dest_path, dest_folder, now_millis, keep_days, newer_file_mode, compare_threshold, compare_version_mode=CompareVersionMode.MODTIME, encryption_settings_provider=<b2sdk._internal.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>, upload_mode=UploadMode.FULL, absolute_minimum_part_size=None)[source]
Bases:
DownPolicy
File is synced down (from the cloud to disk) and the keepDays flag is SET.
- Parameters:
source_path (
Optional
[AbstractPath
]) –source_folder (
AbstractFolder
) –dest_path (
Optional
[AbstractPath
]) –dest_folder (
AbstractFolder
) –now_millis (
int
) –keep_days (
int
) –newer_file_mode (
NewerFileSyncMode
) –compare_threshold (
int
) –compare_version_mode (
CompareVersionMode
) –encryption_settings_provider (
AbstractSyncEncryptionSettingsProvider
) –upload_mode (
UploadMode
) –
- class b2sdk._internal.sync.policy.CopyPolicy(source_path, source_folder, dest_path, dest_folder, now_millis, keep_days, newer_file_mode, compare_threshold, compare_version_mode=CompareVersionMode.MODTIME, encryption_settings_provider=<b2sdk._internal.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>, upload_mode=UploadMode.FULL, absolute_minimum_part_size=None)[source]
Bases:
AbstractFileSyncPolicy
File is copied (server-side).
- Parameters:
source_path (
Optional
[AbstractPath
]) –source_folder (
AbstractFolder
) –dest_path (
Optional
[AbstractPath
]) –dest_folder (
AbstractFolder
) –now_millis (
int
) –keep_days (
int
) –newer_file_mode (
NewerFileSyncMode
) –compare_threshold (
int
) –compare_version_mode (
CompareVersionMode
) –encryption_settings_provider (
AbstractSyncEncryptionSettingsProvider
) –upload_mode (
UploadMode
) –
- DESTINATION_PREFIX = 'b2://'
- SOURCE_PREFIX = 'b2://'
- class b2sdk._internal.sync.policy.CopyAndDeletePolicy(source_path, source_folder, dest_path, dest_folder, now_millis, keep_days, newer_file_mode, compare_threshold, compare_version_mode=CompareVersionMode.MODTIME, encryption_settings_provider=<b2sdk._internal.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>, upload_mode=UploadMode.FULL, absolute_minimum_part_size=None)[source]
Bases:
CopyPolicy
File is copied (server-side) and the delete flag is SET.
- Parameters:
source_path (
Optional
[AbstractPath
]) –source_folder (
AbstractFolder
) –dest_path (
Optional
[AbstractPath
]) –dest_folder (
AbstractFolder
) –now_millis (
int
) –keep_days (
int
) –newer_file_mode (
NewerFileSyncMode
) –compare_threshold (
int
) –compare_version_mode (
CompareVersionMode
) –encryption_settings_provider (
AbstractSyncEncryptionSettingsProvider
) –upload_mode (
UploadMode
) –
- class b2sdk._internal.sync.policy.CopyAndKeepDaysPolicy(source_path, source_folder, dest_path, dest_folder, now_millis, keep_days, newer_file_mode, compare_threshold, compare_version_mode=CompareVersionMode.MODTIME, encryption_settings_provider=<b2sdk._internal.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>, upload_mode=UploadMode.FULL, absolute_minimum_part_size=None)[source]
Bases:
CopyPolicy
File is copied (server-side) and the keepDays flag is SET.
- Parameters:
source_path (
Optional
[AbstractPath
]) –source_folder (
AbstractFolder
) –dest_path (
Optional
[AbstractPath
]) –dest_folder (
AbstractFolder
) –now_millis (
int
) –keep_days (
int
) –newer_file_mode (
NewerFileSyncMode
) –compare_threshold (
int
) –compare_version_mode (
CompareVersionMode
) –encryption_settings_provider (
AbstractSyncEncryptionSettingsProvider
) –upload_mode (
UploadMode
) –
- b2sdk._internal.sync.policy.make_b2_delete_note(version, index, transferred)[source]
Create a note message for delete action.
- Parameters:
version (b2sdk.v2.FileVersion) – an object which contains file version info
index (int) – file version index
transferred (bool) – if True, file has been transferred, False otherwise
- b2sdk._internal.sync.policy.make_b2_delete_actions(source_path, dest_path, dest_folder, transferred)[source]
Create the actions to delete files stored on B2, which are not present locally.
- Parameters:
source_path (
Optional
[AbstractPath
]) – source file objectdest_folder (
AbstractFolder
) – destination foldertransferred (
bool
) – if True, file has been transferred, False otherwise
- b2sdk._internal.sync.policy.make_b2_keep_days_actions(source_path, dest_path, dest_folder, transferred, keep_days, now_millis)[source]
Create 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:
source_path (
Optional
[AbstractPath
]) – source file objectdest_folder (
AbstractFolder
) – destination folder objecttransferred (
bool
) – if True, file has been transferred, False otherwisekeep_days (
int
) – how many days to keep a filenow_millis (
int
) – current time in milliseconds