From 9cbb466ce80096c2c12c88be50e475265adb74b1 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sat, 16 Jan 2021 21:14:15 +0300 Subject: [PATCH] REDO_INODE_NO_TRUST --- doc/faq.texi | 5 +++-- doc/features.texi | 5 +++-- doc/news.texi | 4 ++++ inode.go | 4 ++++ main.go | 1 + ood.go | 2 +- usage.go | 4 +++- 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/doc/faq.texi b/doc/faq.texi index 1c6def3..9b909a6 100644 --- a/doc/faq.texi +++ b/doc/faq.texi @@ -4,8 +4,9 @@ @anchor{Stamping} @section Hashing and stamping -All targets are checksummed if their @file{ctime} differs from the -previous one. @command{apenwarr/redo} gives +All targets are checksummed if no @env{REDO_INODE_NO_TRUST} environment +variable is set and target's @file{ctime} differs from the previous one. +@command{apenwarr/redo} gives @url{https://redo.readthedocs.io/en/latest/FAQImpl/#why-not-always-use-checksum-based-dependencies-instead-of-timestamps, many reasons} why every time checksumming is bad, but in my opinion in practice all of them do not apply. diff --git a/doc/features.texi b/doc/features.texi index 2c5141e..843222d 100644 --- a/doc/features.texi +++ b/doc/features.texi @@ -12,8 +12,9 @@ @end itemize @item targets, dependency information and their directories are explicitly synced (can be disabled, should work faster) -@item file's change is detected by comparing its size, @code{ctime} - and BLAKE3 hash +@item file's change is detected by comparing its size, @code{ctime} (if + @env{REDO_INODE_NO_TRUST} environment variable is not set) and + BLAKE3 hash @item files creation is @code{umask}-friendly (unlike @code{mkstemp()} used in @command{redo-c}) @item parallel build with jobs limit, optionally in infinite mode diff --git a/doc/news.texi b/doc/news.texi index bc4322e..3d5a651 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -7,6 +7,10 @@ @item @code{Size} is stored in the state, for faster OOD detection. Previous @command{goredo} state files won't work. +@item + Setting of @env{REDO_INODE_NO_TRUST} environment variable brings no + trust to file inode's information (except for its size), forcing its + checksum checking. @item @command{redo-whichdo} resembles @code{apenwarr/redo}'s one behaviour more. @end itemize diff --git a/inode.go b/inode.go index 81e77bb..2d929a2 100644 --- a/inode.go +++ b/inode.go @@ -28,6 +28,10 @@ import ( "golang.org/x/sys/unix" ) +const EnvInodeNoTrust = "REDO_INODE_NO_TRUST" + +var InodeTrust bool = false + type Inode struct { Size int64 CtimeSec int64 diff --git a/main.go b/main.go index 873582a..7d1c719 100644 --- a/main.go +++ b/main.go @@ -101,6 +101,7 @@ func main() { NoColor = os.Getenv(EnvNoColor) != "" NoSync = os.Getenv(EnvNoSync) == "1" + InodeTrust = os.Getenv(EnvInodeNoTrust) == "" TopDir = os.Getenv(EnvTopDir) if TopDir == "" { diff --git a/ood.go b/ood.go index e75dd43..5fe1104 100644 --- a/ood.go +++ b/ood.go @@ -139,7 +139,7 @@ func isOOD(cwd, tgtOrig string, level int, seen map[string]struct{}) (bool, erro ood = true goto Done } - if inode.Equals(theirInode) { + if InodeTrust && inode.Equals(theirInode) { trace(CDebug, "ood: %s%s -> %s: same inode", indent, tgtOrig, dep) } else { trace(CDebug, "ood: %s%s -> %s: inode differs", indent, tgtOrig, dep) diff --git a/usage.go b/usage.go index ce838b4..beb221f 100644 --- a/usage.go +++ b/usage.go @@ -91,5 +91,7 @@ Additional environment variables: NO_COLOR -- disable messages colouring REDO_NO_SYNC -- disable files/directories explicit filesystem syncing REDO_TOP_DIR -- do not search for .do above that directory - (it can contain .redo/top as an alternative)`) + (it can contain .redo/top as an alternative) + REDO_INODE_NO_TRUST -- do not trust inode information (except for size) + and always check file's hash`) } -- 2.44.0