File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,6 @@ import (
3535 "github.com/containerd/containerd/log"
3636 "github.com/sirupsen/logrus"
3737
38- "github.com/containerd/continuity"
3938 digest "github.com/opencontainers/go-digest"
4039 ocispec "github.com/opencontainers/image-spec/specs-go/v1"
4140 "github.com/pkg/errors"
@@ -661,6 +660,19 @@ func writeTimestampFile(p string, t time.Time) error {
661660 if err != nil {
662661 return err
663662 }
663+ return atomicWrite (p , b , 0666 )
664+ }
664665
665- return continuity .AtomicWriteFile (p , b , 0666 )
666+ func atomicWrite (path string , data []byte , mode os.FileMode ) error {
667+ tmp := fmt .Sprintf ("%s.tmp" , path )
668+ f , err := os .OpenFile (tmp , os .O_RDWR | os .O_CREATE | os .O_TRUNC | os .O_SYNC , mode )
669+ if err != nil {
670+ return errors .Wrap (err , "create tmp file" )
671+ }
672+ _ , err = f .Write (data )
673+ f .Close ()
674+ if err != nil {
675+ return errors .Wrap (err , "write atomic data" )
676+ }
677+ return os .Rename (tmp , path )
666678}
You can’t perform that action at this time.
0 commit comments