From 3d2efdb8e781a148ab3633405534534dfd8c7545 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Fri, 6 Aug 2021 15:22:38 +0300 Subject: [PATCH] Collision resistant .log-rec extension --- buildlog.go | 2 +- cleanup.go | 2 +- doc/news.texi | 9 +++++++++ run.go | 13 +++++++------ usage.go | 2 +- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/buildlog.go b/buildlog.go index 0564bed..fc12ac7 100644 --- a/buildlog.go +++ b/buildlog.go @@ -76,7 +76,7 @@ func init() { } func parseBuildLogRec(dir, tgt string) (map[string][]string, error) { - fd, err := os.Open(path.Join(dir, RedoDir, tgt+LogSuffix+DepSuffix)) + fd, err := os.Open(path.Join(dir, RedoDir, tgt+LogRecSuffix)) if err != nil { return nil, err } diff --git a/cleanup.go b/cleanup.go index dff0ee0..8c757ae 100644 --- a/cleanup.go +++ b/cleanup.go @@ -66,7 +66,7 @@ func redoDirClean(root, what string) error { switch what { case CleanupLog: if strings.HasSuffix(fi.Name(), LogSuffix) || - strings.HasSuffix(fi.Name(), LogSuffix+DepSuffix) { + strings.HasSuffix(fi.Name(), LogRecSuffix) { fmt.Println(pth) if !*DryRun { if err = os.Remove(pth); err != nil { diff --git a/doc/news.texi b/doc/news.texi index b00f197..650c12c 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -1,6 +1,15 @@ @node News @unnumbered News +@anchor{Release 1_13_0} +@section Release 1.13.0 +@itemize +@item + Use @file{.log-rec} extension, instead of @file{.log.rec}, that + won't collide with already existing @file{.log} and @file{.rec} in + @file{.redo} directory. +@end itemize + @anchor{Release 1_12_0} @section Release 1.12.0 @itemize diff --git a/run.go b/run.go index 1d1138b..ca8eebb 100644 --- a/run.go +++ b/run.go @@ -52,11 +52,12 @@ const ( EnvStderrSilent = "REDO_SILENT" EnvNoSync = "REDO_NO_SYNC" - RedoDir = ".redo" - LockSuffix = ".lock" - DepSuffix = ".rec" - TmpPrefix = ".redo." - LogSuffix = ".log" + RedoDir = ".redo" + LockSuffix = ".lock" + DepSuffix = ".rec" + TmpPrefix = ".redo." + LogSuffix = ".log" + LogRecSuffix = ".log-rec" ) var ( @@ -447,7 +448,7 @@ func runScript(tgtOrig string, errs chan error, traced bool) error { fdStdout.Close() if fdStderr != nil { fdStderr.Close() - logRecPath := path.Join(redoDir, tgt+LogSuffix+DepSuffix) + logRecPath := path.Join(redoDir, tgt+LogRecSuffix) if fdStderr, err = os.OpenFile( logRecPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, diff --git a/usage.go b/usage.go index 38ebb38..c002eeb 100644 --- a/usage.go +++ b/usage.go @@ -24,7 +24,7 @@ import ( ) const ( - Version = "1.12.0" + Version = "1.13.0" Warranty = `Copyright (C) 2020-2021 Sergey Matveev This program is free software: you can redistribute it and/or modify -- 2.44.0