1 | # s3-bsync Copyright (c) 2022 Joshua Stockin |
2 | # <https://joshstock.in> |
3 | # <https://git.joshstock.in/s3-bsync> |
4 | # |
5 | # This software is licensed and distributed under the terms of the MIT License. |
6 | # See the MIT License in the LICENSE file of this project's root folder. |
7 | # |
8 | # This comment block and its contents, including this disclaimer, MUST be |
9 | # preserved in all copies or distributions of this software's source. |
10 |
|
11 | import logging |
12 |
|
13 | from . import * |
14 |
|
15 | logger = logging.getLogger(__name__) |
16 |
|
17 | __all__ = ["run"] |
18 |
|
19 |
|
20 | def run(settings): |
21 | logger.debug("Entering run sequence") |
22 | state = syncfile.syncfile(settings.syncfile) |
23 | if "PURGE" in settings.mode: |
24 | logger.debug("Purging syncfile") |
25 | state.purge() |
26 | logger.debug("Success. Exiting...") |
27 | exit(0) |
28 | if state.file_exists() and not "OVERWRITE" in settings.mode: |
29 | logger.debug("Syncfile exists. Deserializing...") |
30 | state.deserialize() |
31 | if not state.file_exists() and not "INIT" in settings.mode: |
32 | logger.error("Not in INIT mode and state file is nonexistent.") |
33 | exit(1) |
34 | state.serialize() |
35 |
|