Skip to content

Commit

Permalink
更新 Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-cq committed Mar 2, 2024
1 parent 69cbcdc commit 60987a7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/alist-sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ jobs:
cat > alist-backup-config.json << EOF
${{ secrets.ALIST_BACKUP_CONFIG }}
EOF
python3 -m alist_sync sync -c $SYNC_CONFIG
set -ex
./bootstrap.sh main test-config
./bootstrap.sh main sync -c alist-backup-config.json
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local_test*
tmp/
config.json
config.yaml
.DS_Store

.alist-sync-cache/
alist_sync/.alist-sync-cache/
Expand Down
6 changes: 5 additions & 1 deletion alist_sync/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def t_config(config_file: str = Option(None, "--config", "-c", help="配置文

if config_file and Path(config_file).exists():
os.environ["ALIST_SYNC_CONFIG"] = str(Path(config_file).resolve().absolute())
os.environ["_ALIST_SYNC_CONFIG"] = str(Path(config_file).resolve().absolute())

_c = create_config()
echo(_c.dump_to_yaml())
Expand All @@ -48,6 +49,7 @@ def sync(

if config_file and Path(config_file).exists():
os.environ["ALIST_SYNC_CONFIG"] = str(Path(config_file).resolve().absolute())
os.environ["_ALIST_SYNC_CONFIG"] = str(Path(config_file).resolve().absolute())

create_config()
if debug:
Expand All @@ -60,7 +62,9 @@ def sync(
def cli_get(path: str):
""""""
from alist_sdk import login_server, AlistPath
from alist_sync.config import sync_config
from alist_sync.config import create_config

sync_config = create_config()

for s in sync_config.alist_servers:
login_server(**s.dump_for_alist_path())
Expand Down
5 changes: 2 additions & 3 deletions alist_sync/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import builtins
import json
import logging
import os
import time
Expand Down Expand Up @@ -49,7 +48,7 @@ def create_config():

_sync_config = Config.load_from_yaml(config_file)
setattr(builtins, "sync_config", _sync_config)
return sync_config
return _sync_config


class AlistServer(BaseModel):
Expand Down Expand Up @@ -249,7 +248,7 @@ def dump_to_mongodb(self):
)


sync_config = create_config()
# sync_config = create_config()


if __name__ == "__main__":
Expand Down
8 changes: 5 additions & 3 deletions tools/create_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
alist_config = json.loads(PROJECT_ROOT.joinpath("alist/data/config.json").read_text())

alist_port = alist_config["scheme"]["http_port"]
admin_password = os.getenv("_ALIST_ADMIN_PASSWORD", "123456")
admin_password = os.getenv("_ALIST_ADMIN_PASSWORD", ) or "123456"

remote_url = os.getenv("_ALIST_BACKUP_URL")
remote_username = os.getenv("_ALIST_BACKUP_USERNAME")
Expand All @@ -30,9 +30,11 @@
password=admin_password,
)

print("local_client =", admin_password)
# 如果--, 删除全部存储器
if os.getenv("_RELOAD_STORAGE"):
for i in local_client.admin_storage_list().data.content:
print("_RELOAD_STORAGE =", os.getenv("_RELOAD_STORAGE"))
if os.getenv("_RELOAD_STORAGE") == "true":
for i in local_client.admin_storage_list().data.content or []:
local_client.admin_storage_delete(i.id)

# 创建本地存储器
Expand Down

0 comments on commit 60987a7

Please sign in to comment.