mirror of
https://github.com/tuna/tunasync-scripts.git
synced 2025-07-01 15:35:45 +00:00
verify the content of ~5% of files each time, close #25
This commit is contained in:
parent
f268ce316e
commit
e87a55da65
@ -3,6 +3,7 @@ import hashlib
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import random
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess as sp
|
import subprocess as sp
|
||||||
import tempfile
|
import tempfile
|
||||||
@ -169,10 +170,13 @@ def sync_installer(repo_url, local_dir: Path):
|
|||||||
local_filesize = stat.st_size
|
local_filesize = stat.st_size
|
||||||
local_mtime = stat.st_mtime
|
local_mtime = stat.st_mtime
|
||||||
|
|
||||||
if remote_filesize == local_filesize and remote_date.timestamp() == local_mtime:
|
# Do content verification on ~5% of files (see issue #25)
|
||||||
|
if remote_filesize == local_filesize and remote_date.timestamp() == local_mtime and\
|
||||||
|
(random.random() < 0.95 or md5_check(dst_file, md5)):
|
||||||
logging.info("Skipping {}".format(filename))
|
logging.info("Skipping {}".format(filename))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
logging.info("Removing {}".format(filename))
|
||||||
dst_file.unlink()
|
dst_file.unlink()
|
||||||
|
|
||||||
for retry in range(3):
|
for retry in range(3):
|
||||||
@ -197,7 +201,10 @@ def main():
|
|||||||
raise Exception("Working Directory is None")
|
raise Exception("Working Directory is None")
|
||||||
|
|
||||||
working_dir = Path(args.working_dir)
|
working_dir = Path(args.working_dir)
|
||||||
|
random.seed()
|
||||||
|
|
||||||
|
if random.random() < 0.1: # Syncing installer less frequently
|
||||||
|
logging.info("Syncing installers...")
|
||||||
for dist in ("archive", "miniconda"):
|
for dist in ("archive", "miniconda"):
|
||||||
remote_url = "{}/{}".format(CONDA_REPO_BASE_URL, dist)
|
remote_url = "{}/{}".format(CONDA_REPO_BASE_URL, dist)
|
||||||
local_dir = working_dir / dist
|
local_dir = working_dir / dist
|
||||||
|
Loading…
x
Reference in New Issue
Block a user