Skip to content

Commit

Permalink
Forgot to add boilerplate folder to the update cleanup step!
Browse files Browse the repository at this point in the history
  • Loading branch information
tabatkins committed Dec 7, 2021
1 parent a892fb1 commit cace53f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
12 changes: 12 additions & 0 deletions bikeshed/update/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Adding New Update Folders/Files
===============================

When adding new folders, files, or types of updateable data entirely,
make sure to update `manifest.py`'s
`knownFiles` (for top-level files)
and `knownFolders` (for top-level folders),
so it knows where to look when generating manifests.

Also update `main.py`'s `cleanupFiles()`,
so it knows where it can *delete* files,
otherwise phantom paths will stick around over time.
5 changes: 4 additions & 1 deletion bikeshed/update/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def update(
# fmt: on

cleanupFiles(path, touchedPaths=touchedPaths, dryRun=dryRun)
manifest.createManifest(path=path, dryRun=dryRun)
return manifest.createManifest(path=path, dryRun=dryRun)


def fixupDataFiles():
Expand Down Expand Up @@ -136,6 +136,9 @@ def cleanupFiles(root, touchedPaths, dryRun=False):
if touchedPaths["mdn"] is not None:
deletableFolders.extend(["mdn"])
paths.update(touchedPaths["mdn"])
if touchedPaths["boilerplate"] is not None:
deletableFolders.extend(["boilerplate"])
paths.update(touchedPaths["boilerplate"])

say("Cleaning up old data files...")
oldPaths = []
Expand Down
12 changes: 8 additions & 4 deletions bikeshed/update/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ def updateByManifest(path, dryRun=False):
for filePath, hash in remoteFiles.items():
if hash != localFiles.get(filePath):
newPaths.append(filePath)

if not dryRun:
deletedPaths = []
for filePath in localFiles:
Expand All @@ -174,25 +173,30 @@ def updateByManifest(path, dryRun=False):
if deletedPaths:
print("Deleted {} old data file{}.".format(len(deletedPaths), "s" if len(deletedPaths) > 1 else ""))

newManifest = None
if not dryRun:
if newPaths:
say(f"Updating {len(newPaths)} file{'s' if len(newPaths) > 1 else ''}...")
goodPaths, badPaths = asyncio.run(updateFiles(path, newPaths))
newManifest = createFinishedManifest(remoteManifest, goodPaths, badPaths)
try:
with open(os.path.join(path, "manifest.txt"), "w", encoding="utf-8") as fh:
fh.write(createFinishedManifest(remoteManifest, goodPaths, badPaths))
fh.write(newManifest)
except Exception as e:
warn(f"Couldn't save new manifest file.\n{e}")
return False
if newManifest is None:
newManifest = createManifest(path, dryRun=True)

if not badPaths:
say("Done!")
return True
return newManifest
else:
phrase = f"were {len(badPaths)} errors" if len(badPaths) > 1 else "was 1 error"
die(
f"Done, but there {phrase} (of {len(newPaths)} total) in downloading or saving. Run `bikeshed update` again to retry."
)
return True
return newManifest


async def updateFiles(localPrefix, newPaths):
Expand Down

0 comments on commit cace53f

Please sign in to comment.