Skip to content

Instantly share code, notes, and snippets.

@taoky
Created October 30, 2025 17:52
Show Gist options
  • Select an option

  • Save taoky/2c82ca534fa67e1110da1b7eb121aec5 to your computer and use it in GitHub Desktop.

Select an option

Save taoky/2c82ca534fa67e1110da1b7eb121aec5 to your computer and use it in GitHub Desktop.
Debugging quick-fedora-mirror
import os
from pathlib import Path
import logging
os.makedirs("./fedora", exist_ok=True)
filelist = open("fullfiletimelist-fedora")
os.chdir("./fedora")
process_files = False
for line in filelist:
try:
line = line.strip()
if line == "[Files]":
process_files = True
continue
elif process_files and len(line) == 0:
break
if process_files:
timestamp, type_, size, path = line.split("\t", maxsplit=3)
timestamp = int(timestamp)
if type_ == "d":
os.makedirs(path, exist_ok=True)
else:
p = Path(path)
p.parent.mkdir(exist_ok=True, parents=True)
p.touch()
os.truncate(str(p), int(size))
os.utime(path, (timestamp, timestamp))
except:
logging.exception("%s", line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment