dep.rec | 5 +++-- doc/news.texi | 3 +++ doc/ood.texi | 4 ++-- doc/state.texi | 3 +++ inode.go | 13 +++++++++++++ diff --git a/dep.rec b/dep.rec index 461ad420ff3f0aed5588d6d5e33e494d610dbc6526323c088f30b4aeac14d8b8..8274340ba92c530481012fbddb8c3a9d168a50e4dbdf3b00b807701f78715060 100644 --- a/dep.rec +++ b/dep.rec @@ -6,10 +6,11 @@ %rec: Dependency %doc: Dependency information %mandatory: Type -%allowed: Target Size CtimeSec CtimeNsec MtimeSec MtimeNsec Hash -%unique: Type Target Size CtimeSec CtimeNsec MtimeSec MtimeNsec Hash +%allowed: Target Size InodeNum CtimeSec CtimeNsec MtimeSec MtimeNsec Hash +%unique: Type Target Size InodeNum CtimeSec CtimeNsec MtimeSec MtimeNsec Hash %type: Type enum ifcreate ifchange always stamp %type: Size int +%type: InodeNum int %type: CtimeSec int %type: CtimeNsec int %type: MtimeSec int diff --git a/doc/news.texi b/doc/news.texi index bf3800de92480432342d4e91297d2b62a77877866e1f0bda250bf5096ac35dca..cc2609a3b0aacf319656c0bedad1adfc29c8b5e6440bd7d9646445936894cf8a 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -9,6 +9,9 @@ @item @command{redo-ifchange}'s @option{-f} option forces each target rebuilding. Comparing to @command{redo}, it will parallelize the process. +@item + Inode's number is also stored as dependency information, just to + prevent possible @code{ctime} collision of two files. @end itemize @anchor{Release 1_22_0} diff --git a/doc/ood.texi b/doc/ood.texi index a9ab4ad9e048bc23837163994fc8ea44d8a8cfa9872e30da5a15a60b4a021dc4..efa07d516625da49faa33e201200d8090c090c95924a11791edf797e603956df 100644 --- a/doc/ood.texi +++ b/doc/ood.texi @@ -13,8 +13,8 @@ collision-resistant hash function of enough length. @command{goredo} uses @url{https://github.com/BLAKE3-team/BLAKE3, BLAKE3} with 256-bit output for that purpose. -Also it stores file's size. Obviously if size differs, then file's -content too and there is no need to read and hash it. +Also it stores file's size and its inode number. Obviously if size +differs, then file's content too and there is no need to read and hash it. @vindex REDO_INODE_TRUST But still it could be relatively expensive. So there are additional diff --git a/doc/state.texi b/doc/state.texi index 4a76847b7da472555babd1ea9a9dca21170175274e37cc94140998d9a06cc674..38cc997c8a3e7eb1780579bf2a93c2f2de8ee31f0d6cd29f86e4114eb204e7fe 100644 --- a/doc/state.texi +++ b/doc/state.texi @@ -18,8 +18,11 @@ Type: ifchange Target: default.o.do Size: 123 +InodeNum: 2345 CtimeSec: 1605721341 CtimeNsec: 253305000 +MtimeSec: 1645606823 +MtimeNsec: 369936700 Hash: f4929732f96f11e6d4ebe94536b5edef426d00ed0146853e37a87f4295e18eda Type: always diff --git a/inode.go b/inode.go index e95e99a19c090f94cb183ebbf248c66a3c4deabc0dd4b00c12f1742cd50d174e..baa4199ddd3448ce721ac28252c5aa4fcf300e5d5208f2ce59d5664e1a9e91a1 100644 --- a/inode.go +++ b/inode.go @@ -43,6 +43,7 @@ var InodeTrust InodeTrustType type Inode struct { Size int64 + InodeNum uint64 CtimeSec int64 CtimeNsec int64 MtimeSec int64 @@ -51,6 +52,9 @@ } func (our *Inode) Equals(their *Inode) bool { if our.Size != their.Size { + return false + } + if our.InodeNum != their.InodeNum { return false } switch InodeTrust { @@ -72,6 +76,7 @@ func (inode *Inode) RecfileFields() []recfile.Field { return []recfile.Field{ {Name: "Size", Value: strconv.FormatInt(inode.Size, 10)}, + {Name: "InodeNum", Value: strconv.FormatUint(inode.InodeNum, 10)}, {Name: "CtimeSec", Value: strconv.FormatInt(inode.CtimeSec, 10)}, {Name: "CtimeNsec", Value: strconv.FormatInt(inode.CtimeNsec, 10)}, {Name: "MtimeSec", Value: strconv.FormatInt(inode.MtimeSec, 10)}, @@ -95,6 +100,7 @@ mtimeSec := fi.ModTime().Unix() mtimeNsec := fi.ModTime().UnixNano() return &Inode{ Size: fi.Size(), + InodeNum: uint64(stat.Ino), CtimeSec: ctimeSec, CtimeNsec: ctimeNsec, MtimeSec: mtimeSec, MtimeNsec: mtimeNsec, }, nil @@ -102,6 +108,7 @@ } func inodeFromRec(m map[string]string) (*Inode, error) { size := m["Size"] + inodeNum := m["InodeNum"] ctimeSec := m["CtimeSec"] ctimeNsec := m["CtimeNsec"] mtimeSec := m["MtimeSec"] @@ -120,6 +127,12 @@ var err error inode.Size, err = strconv.ParseInt(size, 10, 64) if err != nil { return nil, err + } + if inodeNum != "" { + inode.InodeNum, err = strconv.ParseUint(inodeNum, 10, 64) + if err != nil { + return nil, err + } } inode.CtimeSec, err = strconv.ParseInt(ctimeSec, 10, 64) if err != nil {