Files
drobboxordinacebackup/indexer/scanner.py
2026-02-08 12:28:54 +01:00

22 lines
692 B
Python

import os
from datetime import datetime
from indexer.hasher import blake3_file
def scan_files(root_path):
for root, _, files in os.walk(root_path):
for name in files:
full_path = os.path.join(root, name)
try:
stat = os.stat(full_path)
except FileNotFoundError:
continue
yield {
"full_path": full_path.replace("\\", "/"),
"file_name": name,
"directory": root.replace("\\", "/"),
"size": stat.st_size,
"mtime": datetime.fromtimestamp(stat.st_mtime),
"content_hash": blake3_file(full_path),
}