File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,20 @@ func writeNewHardLink(fpath string, target string) error {
133133 return fmt .Errorf ("%s: making directory for file: %v" , fpath , err )
134134 }
135135
136+ // The unarchiving process is unordered, and a hardlinked file's target may not yet exist.
137+ // Create it. writeNewFile() will overwrite it later, which is okay.
138+ if ! fileExists (target ) {
139+ err = os .MkdirAll (filepath .Dir (target ), 0755 )
140+ if err != nil {
141+ return fmt .Errorf ("%s: making directory for file: %v" , target , err )
142+ }
143+ f , err := os .Create (target )
144+ if err != nil {
145+ return fmt .Errorf ("%s: creating target file: %v" , target , err )
146+ }
147+ f .Close ()
148+ }
149+
136150 err = os .Link (target , fpath )
137151 if err != nil {
138152 return fmt .Errorf ("%s: making hard link for: %v" , fpath , err )
You can’t perform that action at this time.
0 commit comments