diff options
author | Nick White <git@njw.name> | 2022-01-17 13:10:33 +0000 |
---|---|---|
committer | Nick White <git@njw.name> | 2022-01-17 13:10:33 +0000 |
commit | cbd4adcdf3b27fc157df526fcdcbac8d6b74bb81 (patch) | |
tree | f347d57cf259a5336c5cd3573fb4e9ba52571bdf /internal | |
parent | db68150149ae3a876962195b50721c17a19c9b63 (diff) |
internal/pipeline: if a graph cannot be created, don't leave an empty graph.png file, and allow failure to download that as it won't be created in the case of a 1 page book, which is fine
Diffstat (limited to 'internal')
-rw-r--r-- | internal/pipeline/get.go | 3 | ||||
-rw-r--r-- | internal/pipeline/pipeline.go | 7 |
2 files changed, 8 insertions, 2 deletions
diff --git a/internal/pipeline/get.go b/internal/pipeline/get.go index 5e43c2b..de4ac3b 100644 --- a/internal/pipeline/get.go +++ b/internal/pipeline/get.go @@ -90,7 +90,8 @@ func DownloadAnalyses(dir string, name string, conn Downloader) error { key := filepath.Join(name, a) fn := filepath.Join(dir, a) err := conn.Download(conn.WIPStorageId(), key, fn) - if err != nil { + // ignore errors with graph.png, as it will not exist in the case of a 1 page book + if err != nil && a != "graph.png" { return fmt.Errorf("Failed to download analysis file %s: %v", key, err) } } diff --git a/internal/pipeline/pipeline.go b/internal/pipeline/pipeline.go index e1a2c40..d5e8e1c 100644 --- a/internal/pipeline/pipeline.go +++ b/internal/pipeline/pipeline.go @@ -467,11 +467,16 @@ func Analyse(conn Downloader) func(chan string, chan string, chan error, *log.Lo } defer f.Close() err = bookpipeline.Graph(bestconfs, filepath.Base(savedir), f) + if err != nil { + _ = os.Remove(fn) + } if err != nil && err.Error() != "Not enough valid confidences" { errc <- fmt.Errorf("Error rendering graph: %s", err) return } - up <- fn + if err == nil { + up <- fn + } close(up) } |