Skip to content

Commit cace53f

Browse files
committed
Forgot to add boilerplate folder to the update cleanup step!
1 parent a892fb1 commit cace53f

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

bikeshed/update/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Adding New Update Folders/Files
2+
===============================
3+
4+
When adding new folders, files, or types of updateable data entirely,
5+
make sure to update `manifest.py`'s
6+
`knownFiles` (for top-level files)
7+
and `knownFolders` (for top-level folders),
8+
so it knows where to look when generating manifests.
9+
10+
Also update `main.py`'s `cleanupFiles()`,
11+
so it knows where it can *delete* files,
12+
otherwise phantom paths will stick around over time.

bikeshed/update/main.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def update(
6262
# fmt: on
6363

6464
cleanupFiles(path, touchedPaths=touchedPaths, dryRun=dryRun)
65-
manifest.createManifest(path=path, dryRun=dryRun)
65+
return manifest.createManifest(path=path, dryRun=dryRun)
6666

6767

6868
def fixupDataFiles():
@@ -136,6 +136,9 @@ def cleanupFiles(root, touchedPaths, dryRun=False):
136136
if touchedPaths["mdn"] is not None:
137137
deletableFolders.extend(["mdn"])
138138
paths.update(touchedPaths["mdn"])
139+
if touchedPaths["boilerplate"] is not None:
140+
deletableFolders.extend(["boilerplate"])
141+
paths.update(touchedPaths["boilerplate"])
139142

140143
say("Cleaning up old data files...")
141144
oldPaths = []

bikeshed/update/manifest.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ def updateByManifest(path, dryRun=False):
164164
for filePath, hash in remoteFiles.items():
165165
if hash != localFiles.get(filePath):
166166
newPaths.append(filePath)
167-
168167
if not dryRun:
169168
deletedPaths = []
170169
for filePath in localFiles:
@@ -174,25 +173,30 @@ def updateByManifest(path, dryRun=False):
174173
if deletedPaths:
175174
print("Deleted {} old data file{}.".format(len(deletedPaths), "s" if len(deletedPaths) > 1 else ""))
176175

176+
newManifest = None
177177
if not dryRun:
178178
if newPaths:
179179
say(f"Updating {len(newPaths)} file{'s' if len(newPaths) > 1 else ''}...")
180180
goodPaths, badPaths = asyncio.run(updateFiles(path, newPaths))
181+
newManifest = createFinishedManifest(remoteManifest, goodPaths, badPaths)
181182
try:
182183
with open(os.path.join(path, "manifest.txt"), "w", encoding="utf-8") as fh:
183-
fh.write(createFinishedManifest(remoteManifest, goodPaths, badPaths))
184+
fh.write(newManifest)
184185
except Exception as e:
185186
warn(f"Couldn't save new manifest file.\n{e}")
186187
return False
188+
if newManifest is None:
189+
newManifest = createManifest(path, dryRun=True)
190+
187191
if not badPaths:
188192
say("Done!")
189-
return True
193+
return newManifest
190194
else:
191195
phrase = f"were {len(badPaths)} errors" if len(badPaths) > 1 else "was 1 error"
192196
die(
193197
f"Done, but there {phrase} (of {len(newPaths)} total) in downloading or saving. Run `bikeshed update` again to retry."
194198
)
195-
return True
199+
return newManifest
196200

197201

198202
async def updateFiles(localPrefix, newPaths):

0 commit comments

Comments
 (0)