notebook
This commit is contained in:
21
indexer/scanner.py
Normal file
21
indexer/scanner.py
Normal file
@@ -0,0 +1,21 @@
|
||||
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),
|
||||
}
|
||||
Reference in New Issue
Block a user