Answer the stability and product-owner reviews' first round
This commit is contained in:
@@ -30,15 +30,14 @@ def archive(project_key: str, path: str, note: str, paths: Paths) -> Failure | N
|
||||
return None
|
||||
|
||||
|
||||
# Claude Code only appends to a session folder's files, so overwriting a copy loses nothing.
|
||||
def mirror(source: pathlib.Path, dest: pathlib.Path) -> Failure | None:
|
||||
for file in sorted(source.rglob("*")):
|
||||
copy = dest / file.relative_to(source)
|
||||
try:
|
||||
if not file.is_file():
|
||||
continue
|
||||
data = file.read_bytes()
|
||||
if copy.is_file() and copy.read_bytes() == data:
|
||||
copy = copy_for(dest / file.relative_to(source), data)
|
||||
if copy is None:
|
||||
continue
|
||||
make_private(copy.parent)
|
||||
except OSError as failure:
|
||||
@@ -46,3 +45,14 @@ def mirror(source: pathlib.Path, dest: pathlib.Path) -> Failure | None:
|
||||
if unwritten := replace_file(copy, data):
|
||||
return Failure(f"could not archive the transcript: {copy}: {unwritten.reason}")
|
||||
return None
|
||||
|
||||
|
||||
# Every chunk of a project reuses its session id, so a name can recur with other content: only a file that grew from its copy replaces it.
|
||||
def copy_for(copy: pathlib.Path, data: bytes) -> pathlib.Path | None:
|
||||
if not copy.is_file():
|
||||
return copy
|
||||
kept = copy.read_bytes()
|
||||
if data.startswith(kept):
|
||||
return copy if data != kept else None
|
||||
beside = copy.with_name(f"{copy.name}.{hashlib.sha256(data).hexdigest()}")
|
||||
return None if beside.exists() else beside
|
||||
|
||||
Reference in New Issue
Block a user