b2sdk._internal.sync.action

class b2sdk._internal.sync.action.AbstractAction[source]

Bases: object

An action to take, such as uploading, downloading, or deleting a file. Multi-threaded tasks create a sequence of Actions which are then run by a pool of threads.

An action can depend on other actions completing. An example of this is making sure a CreateBucketAction happens before an UploadFileAction.

run(bucket, reporter, dry_run=False)[source]

Main action routine.

Parameters:
  • bucket (b2sdk._internal.bucket.Bucket) – a Bucket object

  • reporter (ProgressReport) – a place to report errors

  • dry_run (bool) – if True, perform a dry run

abstract get_bytes()[source]

Return the number of bytes to transfer for this action.

Return type:

int

abstract do_action(bucket, reporter)[source]

Perform the action, returning only after the action is completed.

Parameters:
  • bucket (Bucket) – a Bucket object

  • reporter (ProgressReport) – a place to report errors

Return type:

None

abstract do_report(bucket, reporter)[source]

Report the action performed.

Parameters:
  • bucket (Bucket) – a Bucket object

  • reporter (ProgressReport) – a place to report errors

Return type:

None

class b2sdk._internal.sync.action.B2UploadAction(local_full_path, relative_name, b2_file_name, mod_time_millis, size, encryption_settings_provider)[source]

Bases: AbstractAction

File uploading action.

Parameters:
__init__(local_full_path, relative_name, b2_file_name, mod_time_millis, size, encryption_settings_provider)[source]
Parameters:
  • local_full_path (str) – a local file path

  • relative_name (str) – a relative file name

  • b2_file_name (str) – a name of a new remote file

  • mod_time_millis (int) – file modification time in milliseconds

  • size (int) – a file size

  • encryption_settings_provider (AbstractSyncEncryptionSettingsProvider) – encryption setting provider

get_bytes()[source]

Return file size.

Return type:

int

get_all_sources()[source]

Get list of sources required to complete this upload

Return type:

list[OutboundTransferSource]

do_action(bucket, reporter)[source]

Perform the uploading action, returning only after the action is completed.

Parameters:
  • bucket (Bucket) – a Bucket object

  • reporter (ProgressReport) – a place to report errors

Return type:

None

do_report(bucket, reporter)[source]

Report the uploading action performed.

Parameters:
  • bucket (Bucket) – a Bucket object

  • reporter (ProgressReport) – a place to report errors

Return type:

None

class b2sdk._internal.sync.action.B2IncrementalUploadAction(local_full_path, relative_name, b2_file_name, mod_time_millis, size, encryption_settings_provider, file_version=None, absolute_minimum_part_size=None)[source]

Bases: B2UploadAction

Parameters:
__init__(local_full_path, relative_name, b2_file_name, mod_time_millis, size, encryption_settings_provider, file_version=None, absolute_minimum_part_size=None)[source]
Parameters:
  • local_full_path (str) – a local file path

  • relative_name (str) – a relative file name

  • b2_file_name (str) – a name of a new remote file

  • mod_time_millis (int) – file modification time in milliseconds

  • size (int) – a file size

  • encryption_settings_provider (AbstractSyncEncryptionSettingsProvider) – encryption setting provider

  • file_version (Optional[FileVersion]) – version of file currently on the server

  • absolute_minimum_part_size (Optional[int]) – minimum file part size for large files

get_all_sources()[source]

Get list of sources required to complete this upload

Return type:

list[OutboundTransferSource]

class b2sdk._internal.sync.action.B2HideAction(relative_name, b2_file_name)[source]

Bases: AbstractAction

Parameters:
  • relative_name (str) –

  • b2_file_name (str) –

__init__(relative_name, b2_file_name)[source]
Parameters:
  • relative_name (str) – a relative file name

  • b2_file_name (str) – a name of a remote file

get_bytes()[source]

Return file size.

Returns:

always zero

Return type:

int

do_action(bucket, reporter)[source]

Perform the hiding action, returning only after the action is completed.

Parameters:
  • bucket (Bucket) – a Bucket object

  • reporter (ProgressReport) – a place to report errors

Return type:

None

do_report(bucket, reporter)[source]

Report the hiding action performed.

Parameters:
  • bucket (Bucket) – a Bucket object

  • reporter (SyncReport) – a place to report errors

class b2sdk._internal.sync.action.B2DownloadAction(source_path, b2_file_name, local_full_path, encryption_settings_provider)[source]

Bases: AbstractAction

Parameters:
__init__(source_path, b2_file_name, local_full_path, encryption_settings_provider)[source]
Parameters:
get_bytes()[source]

Return file size.

Return type:

int

do_action(bucket, reporter)[source]

Perform the downloading action, returning only after the action is completed.

Parameters:
  • bucket (Bucket) – a Bucket object

  • reporter (ProgressReport) – a place to report errors

Return type:

None

do_report(bucket, reporter)[source]

Report the downloading action performed.

Parameters:
  • bucket (Bucket) – a Bucket object

  • reporter (ProgressReport) – a place to report errors

Return type:

None

class b2sdk._internal.sync.action.B2CopyAction(b2_file_name, source_path, dest_b2_file_name, source_bucket, destination_bucket, encryption_settings_provider)[source]

Bases: AbstractAction

File copying action.

Parameters:
__init__(b2_file_name, source_path, dest_b2_file_name, source_bucket, destination_bucket, encryption_settings_provider)[source]
Parameters:
  • b2_file_name (str) – a b2_file_name

  • source_path (B2Path) – the file to be copied

  • dest_b2_file_name – a name of a destination remote file

  • source_bucket (Bucket) – bucket to copy from

  • destination_bucket (Bucket) – bucket to copy to

  • encryption_settings_provider (AbstractSyncEncryptionSettingsProvider) – encryption setting provider

get_bytes()[source]

Return file size.

Return type:

int

do_action(bucket, reporter)[source]

Perform the copying action, returning only after the action is completed.

Parameters:
  • bucket (Bucket) – a Bucket object

  • reporter (ProgressReport) – a place to report errors

Return type:

None

do_report(bucket, reporter)[source]

Report the copying action performed.

Parameters:
  • bucket (Bucket) – a Bucket object

  • reporter (ProgressReport) – a place to report errors

Return type:

None

class b2sdk._internal.sync.action.B2DeleteAction(relative_name, b2_file_name, file_id, note)[source]

Bases: AbstractAction

Parameters:
  • relative_name (str) –

  • b2_file_name (str) –

  • file_id (str) –

  • note (str) –

__init__(relative_name, b2_file_name, file_id, note)[source]
Parameters:
  • relative_name (str) – a relative file name

  • b2_file_name (str) – a name of a remote file

  • file_id (str) – a file ID

  • note (str) – a deletion note

get_bytes()[source]

Return file size.

Return type:

int

Returns:

always zero

do_action(bucket, reporter)[source]

Perform the deleting action, returning only after the action is completed.

Parameters:
  • bucket (Bucket) – a Bucket object

  • reporter (ProgressReport) – a place to report errors

do_report(bucket, reporter)[source]

Report the deleting action performed.

Parameters:
  • bucket (Bucket) – a Bucket object

  • reporter (SyncReport) – a place to report errors

class b2sdk._internal.sync.action.LocalDeleteAction(relative_name, full_path)[source]

Bases: AbstractAction

Parameters:
  • relative_name (str) –

  • full_path (str) –

__init__(relative_name, full_path)[source]
Parameters:
  • relative_name (str) – a relative file name

  • full_path (str) – a full local path

get_bytes()[source]

Return file size.

Return type:

int

Returns:

always zero

do_action(bucket, reporter)[source]

Perform the deleting of a local file action, returning only after the action is completed.

Parameters:
  • bucket (Bucket) – a Bucket object

  • reporter (ProgressReport) – a place to report errors

do_report(bucket, reporter)[source]

Report the deleting of a local file action performed.

Parameters:
  • bucket (Bucket) – a Bucket object

  • reporter (SyncReport) – a place to report errors