cys003 commited on
Commit
478dee6
·
verified ·
1 Parent(s): c0123b2

Update sync.py

Browse files
Files changed (1) hide show
  1. sync.py +2 -6
sync.py CHANGED
@@ -3,12 +3,10 @@ import tarfile
3
  import time
4
  from huggingface_hub import hf_hub_download, upload_file
5
 
6
- # ================== 请修改这里 ==================
7
- DATASET_REPO = "cys003/chromium-config" # ← 改成你实际新建的 Dataset
8
  FILE_NAME = "config.tar.gz"
9
  CONFIG_DIR = "/config"
10
  TOKEN = os.environ.get("HF_TOKEN")
11
- # ===============================================
12
 
13
  def restore():
14
  print("=== 开始执行 Chromium 配置恢复 ===")
@@ -20,11 +18,10 @@ def restore():
20
  token=TOKEN
21
  )
22
  os.makedirs(CONFIG_DIR, exist_ok=True)
23
-
24
  with tarfile.open(local_file, "r:gz") as tar:
25
  tar.extractall(CONFIG_DIR, filter='data')
26
 
27
- # 清理 Chromium 锁文件,防止 "already running" 错误
28
  for lock_file in ["SingletonLock", "SingletonSocket", "SingletonCookie", ".lock"]:
29
  lock_path = os.path.join(CONFIG_DIR, lock_file)
30
  if os.path.exists(lock_path):
@@ -41,7 +38,6 @@ def backup():
41
  tar_path = "/tmp/config.tar.gz"
42
  with tarfile.open(tar_path, "w:gz") as tar:
43
  tar.add(CONFIG_DIR, arcname=".")
44
-
45
  upload_file(
46
  path_or_fileobj=tar_path,
47
  path_in_repo=FILE_NAME,
 
3
  import time
4
  from huggingface_hub import hf_hub_download, upload_file
5
 
6
+ DATASET_REPO = "cys003/chromium-config" # ← 确认是这个
 
7
  FILE_NAME = "config.tar.gz"
8
  CONFIG_DIR = "/config"
9
  TOKEN = os.environ.get("HF_TOKEN")
 
10
 
11
  def restore():
12
  print("=== 开始执行 Chromium 配置恢复 ===")
 
18
  token=TOKEN
19
  )
20
  os.makedirs(CONFIG_DIR, exist_ok=True)
 
21
  with tarfile.open(local_file, "r:gz") as tar:
22
  tar.extractall(CONFIG_DIR, filter='data')
23
 
24
+ # 清理锁文件
25
  for lock_file in ["SingletonLock", "SingletonSocket", "SingletonCookie", ".lock"]:
26
  lock_path = os.path.join(CONFIG_DIR, lock_file)
27
  if os.path.exists(lock_path):
 
38
  tar_path = "/tmp/config.tar.gz"
39
  with tarfile.open(tar_path, "w:gz") as tar:
40
  tar.add(CONFIG_DIR, arcname=".")
 
41
  upload_file(
42
  path_or_fileobj=tar_path,
43
  path_in_repo=FILE_NAME,