diff options
| author | Shulhan <ms@kilabit.info> | 2021-07-30 21:03:39 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-07-30 21:03:39 +0700 |
| commit | 5e34c75a8fd5c89d7fd9aa5951341b42b4edbe63 (patch) | |
| tree | 05a817d57dbc99b827af026baf9b49bd2d349c1e | |
| parent | 942efa6c66cda97d6fe02e02c4479930a47f6b4c (diff) | |
| download | pakakeh.go-5e34c75a8fd5c89d7fd9aa5951341b42b4edbe63.tar.xz | |
lib/memfs: add internal method to reset modTime
The resetAllModTime method set the modTime field from Root to its child
to the value in parameter.
| -rw-r--r-- | lib/memfs/memfs.go | 9 | ||||
| -rw-r--r-- | lib/memfs/node.go | 11 |
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/memfs/memfs.go b/lib/memfs/memfs.go index 03fac234..9ea03553 100644 --- a/lib/memfs/memfs.go +++ b/lib/memfs/memfs.go @@ -16,6 +16,7 @@ import ( "regexp" "sort" "strings" + "time" libbytes "github.com/shuLhan/share/lib/bytes" libints "github.com/shuLhan/share/lib/ints" @@ -657,3 +658,11 @@ func (mfs *MemFS) refresh(url string) (node *Node, err error) { return node, nil } + +// +// resetAllModTime set the modTime on Root and its childs to the t. +// This method is only intended for testing. +// +func (mfs *MemFS) resetAllModTime(t time.Time) { + mfs.Root.resetAllModTime(t) +} diff --git a/lib/memfs/node.go b/lib/memfs/node.go index e89ef99f..2940fc6f 100644 --- a/lib/memfs/node.go +++ b/lib/memfs/node.go @@ -382,6 +382,17 @@ func (leaf *Node) removeChild(child *Node) *Node { } // +// resetAllModTime set the modTime of node and its child to the t. +// This method is only intended for testing. +// +func (leaf *Node) resetAllModTime(t time.Time) { + leaf.modTime = t + for _, c := range leaf.Childs { + c.resetAllModTime(t) + } +} + +// // update the node content and information based on new file information. // // If the newInfo is nil, it will read the file information based on node's |
