WriteFile implements restore.Output interface.
(ctx context.Context, relativePath string, f fs.File, _ FileWriteProgress)
| 49 | |
| 50 | // WriteFile implements restore.Output interface. |
| 51 | func (o *ShallowFilesystemOutput) WriteFile(ctx context.Context, relativePath string, f fs.File, _ FileWriteProgress) error { |
| 52 | log(ctx).Debugf("(Shallow) WriteFile %v (%v bytes) %v, %v", filepath.Join(o.TargetPath, relativePath), f.Size(), f.Mode(), f.ModTime()) |
| 53 | |
| 54 | mde, ok := f.(snapshot.HasDirEntry) |
| 55 | if !ok { |
| 56 | return errors.Errorf("fs object '%s' is not HasDirEntry?", f.Name()) |
| 57 | } |
| 58 | |
| 59 | de := mde.DirEntry() |
| 60 | |
| 61 | // Write small files directly instead of writing placeholders. |
| 62 | if de.FileSize < int64(o.MinSizeForPlaceholder) { |
| 63 | return o.FilesystemOutput.WriteFile(ctx, relativePath, f, nil) |
| 64 | } |
| 65 | |
| 66 | placeholderpath, err := o.writeShallowEntry(ctx, relativePath, de) |
| 67 | if err != nil { |
| 68 | return errors.Wrap(err, "shallow WriteFile") |
| 69 | } |
| 70 | |
| 71 | return o.setAttributes(placeholderpath, f, readonlyfilemode) |
| 72 | } |
| 73 | |
| 74 | const readonlyfilemode = 0o222 |
| 75 |
nothing calls this directly
no test coverage detected