flzta commited on
Commit
095175c
·
verified ·
1 Parent(s): 2b93642

Update sync_data.sh

Browse files
Files changed (1) hide show
  1. sync_data.sh +25 -14
sync_data.sh CHANGED
@@ -107,24 +107,35 @@ try:
107
 
108
  if filepath and os.path.exists(filepath):
109
  print(f'Successfully downloaded backup to temporary directory: {filepath}')
110
- echo \"Before restoring backup:\"
111
- ls -l \"$CLOUDREVE_DIR\"
 
112
 
113
  # 删除现有的 Cloudreve 目录和配置文件
114
- cd \"$CLOUDREVE_DIR\"
115
- echo \"Deleting existing Cloudreve files...\"
116
- rm -rf cloudreve
117
- rm -rf cloudreve.db
118
- rm -rf config.ini
119
- echo \"Deletion complete.\"
120
-
121
- echo \"Extracting backup archive: $filepath to $CLOUDREVE_DIR\"
 
 
 
 
 
 
 
 
 
 
122
  with tarfile.open(filepath, 'r:gz') as tar:
123
  tar.extractall(\"$CLOUDREVE_DIR\")
124
- echo f'Successfully restored backup from {latest_backup}'
125
 
126
- echo \"After restoring backup:\"
127
- ls -l \"$CLOUDREVE_DIR\"
128
  else:
129
  print('Error during file download.')
130
 
@@ -166,7 +177,7 @@ sync_data() {
166
  echo "Cloudreve directory does not exist yet, waiting for next sync..."
167
  fi
168
 
169
- SYNC_INTERVAL=${SYNC_INTERVAL:-60} # 默认同步间隔改为 60 秒。
170
  echo "Next sync in ${SYNC_INTERVAL} seconds..."
171
  sleep $SYNC_INTERVAL
172
  done
 
107
 
108
  if filepath and os.path.exists(filepath):
109
  print(f'Successfully downloaded backup to temporary directory: {filepath}')
110
+ print(\"Before restoring backup:\")
111
+ import subprocess
112
+ subprocess.run(['ls', '-l', \"$CLOUDREVE_DIR\"])
113
 
114
  # 删除现有的 Cloudreve 目录和配置文件
115
+ import shutil
116
+ cloudreve_path = os.path.join(\"$CLOUDREVE_DIR\", \"cloudreve\")
117
+ cloudreve_db_path = os.path.join(\"$CLOUDREVE_DIR\", \"cloudreve.db\")
118
+ config_ini_path = os.path.join(\"$CLOUDREVE_DIR\", \"config.ini\")
119
+
120
+ if os.path.exists(cloudreve_path):
121
+ print(f'Deleting: {cloudreve_path}')
122
+ shutil.rmtree(cloudreve_path, ignore_errors=True)
123
+ if os.path.exists(cloudreve_db_path):
124
+ print(f'Deleting: {cloudreve_db_path}')
125
+ os.remove(cloudreve_db_path)
126
+ if os.path.exists(config_ini_path):
127
+ print(f'Deleting: {config_ini_path}')
128
+ os.remove(config_ini_path)
129
+ print(\"Deletion complete.\")
130
+
131
+ print(f'Extracting backup archive: {filepath} to $CLOUDREVE_DIR')
132
+ import tarfile
133
  with tarfile.open(filepath, 'r:gz') as tar:
134
  tar.extractall(\"$CLOUDREVE_DIR\")
135
+ print(f'Successfully restored backup from {latest_backup}')
136
 
137
+ print(\"After restoring backup:\")
138
+ subprocess.run(['ls', '-l', \"$CLOUDREVE_DIR\"])
139
  else:
140
  print('Error during file download.')
141
 
 
177
  echo "Cloudreve directory does not exist yet, waiting for next sync..."
178
  fi
179
 
180
+ SYNC_INTERVAL=${SYNC_INTERVAL:-60} # 默认同步间隔改为 60
181
  echo "Next sync in ${SYNC_INTERVAL} seconds..."
182
  sleep $SYNC_INTERVAL
183
  done