b2sdk.sync.action – Sync action

class b2sdk.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.

abstract do_action(bucket, reporter)[source]

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

Parameters
abstract do_report(bucket, reporter)[source]

Report the action performed.

Parameters
abstract get_bytes()[source]

Returns the number of bytes to transfer for this action.

Return type

int

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

Main action routine

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

  • reporter – a place to report errors

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

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

Bases: b2sdk.sync.action.AbstractAction

__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

do_action(bucket, reporter)[source]

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

Parameters
do_report(bucket, reporter)[source]

Report the deleting action performed.

Parameters
get_bytes()[source]

Return file size

Returns

always zero

Return type

int

class b2sdk.sync.action.B2DownloadAction(relative_name, b2_file_name, file_id, local_full_path, mod_time_millis, file_size)[source]

Bases: b2sdk.sync.action.AbstractAction

__init__(relative_name, b2_file_name, file_id, local_full_path, mod_time_millis, file_size)[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

  • local_full_path (str) – a local file path

  • mod_time_millis (int) – file modification time in milliseconds

  • file_size (int) – a file size

do_action(bucket, reporter)[source]

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

Parameters
do_report(bucket, reporter)[source]

Report the downloading action performed.

Parameters
get_bytes()[source]

Return file size

Return type

int

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

Bases: b2sdk.sync.action.AbstractAction

__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

do_action(bucket, reporter)[source]

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

Parameters
do_report(bucket, reporter)[source]

Report the hiding action performed.

Parameters
get_bytes()[source]

Return file size

Returns

always zero

Return type

int

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

Bases: b2sdk.sync.action.AbstractAction

File uploading action

__init__(local_full_path, relative_name, b2_file_name, mod_time_millis, size)[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

do_action(bucket, reporter)[source]

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

Parameters
do_report(bucket, reporter)[source]

Report the uploading action performed.

Parameters
get_bytes()[source]

Return file size

Return type

int

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

Bases: b2sdk.sync.action.AbstractAction

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

  • full_path – a full local path

Type

str

do_action(bucket, reporter)[source]

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

Parameters
do_report(bucket, reporter)[source]

Report the deleting of a local file action performed.

Parameters
get_bytes()[source]

Return file size

Returns

always zero

Return type

int