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 @@ -132,6 +132,20 @@ func writeNewHardLink(fpath string, target string) error {
132132 return fmt .Errorf ("%s: making directory for file: %v" , fpath , err )
133133 }
134134
135+ // The unarchiving process is unordered, and a hardlinked file's target may not yet exist.
136+ // Create it. writeNewFile() will overwrite it later, which is okay.
137+ if ! fileExists (target ) {
138+ err = os .MkdirAll (filepath .Dir (target ), 0755 )
139+ if err != nil {
140+ return fmt .Errorf ("%s: making directory for file: %v" , target , err )
141+ }
142+ f , err := os .Create (target )
143+ if err != nil {
144+ return fmt .Errorf ("%s: creating target file: %v" , target , err )
145+ }
146+ f .Close ()
147+ }
148+
135149 err = os .Link (target , fpath )
136150 if err != nil {
137151 return fmt .Errorf ("%s: making hard link for: %v" , fpath , err )
You can’t perform that action at this time.
0 commit comments