Skip to content

Commit 5d2d50d

Browse files
committed
Hasher exit when hash dir empty. Fixes #204
1 parent 42fc552 commit 5d2d50d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Do not hide the download speed label, even if the speed is zero.
1111
* The download-speed label now shows a 3 second average.
1212
* `hasher` will no longer blindly overwrite an existing bundleinfo.json but instead error out.
13+
* `hasher` will now exit with an error when the `pathToHash` has no files to hash.
1314
### Features
1415
* trivrost will log the progress of downloads if the connection was interrupted for any reason.
1516
### Fixes

cmd/hasher/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,16 @@ func mustHashDirectory(uniqueBundleName, pathToHash, hashesFile string) {
4747
log.Panicf("\"%s\" must be a directory.", pathToHash)
4848
}
4949
_, checkErr := os.Stat(filepath.Join(pathToHash, bundlefilename))
50-
if checkErr == nil || os.IsExist(checkErr) {
50+
if checkErr == nil || os.IsExist(checkErr) {
5151
log.Panicf("Found existing \"%s\", aborting!", filepath.Join(pathToHash, bundlefilename))
5252
}
5353
bundleInfo := &config.BundleInfo{
5454
BundleFiles: hashing.MustHash(context.Background(), pathToHash),
5555
Timestamp: time.Now().UTC().Format(timeFormat),
5656
UniqueBundleName: uniqueBundleName,
5757
}
58+
if len(bundleInfo.BundleFiles) == 0 {
59+
log.Panicf("No files to hash at %v", pathToHash)
60+
}
5861
config.WriteInfo(bundleInfo, hashesFile)
5962
}

0 commit comments

Comments
 (0)