internalCopy performs a simple copy from source to destination. This in itself is not safe.
(sourcePath, destinationPath string)
| 187 | // internalCopy performs a simple copy from source to destination. |
| 188 | // This in itself is not safe. |
| 189 | func internalCopy(sourcePath, destinationPath string) (err error) { |
| 190 | var source *os.File |
| 191 | |
| 192 | // Open source |
| 193 | source, err = os.OpenFile(sourcePath, os.O_RDONLY, privateFilePermission) |
| 194 | if err != nil { |
| 195 | return err |
| 196 | } |
| 197 | |
| 198 | defer func() { |
| 199 | err = errors.Join(err, source.Close()) |
| 200 | }() |
| 201 | |
| 202 | // Read file length |
| 203 | srcInfo, err := source.Stat() |
| 204 | if err != nil { |
| 205 | return err |
| 206 | } |
| 207 | |
| 208 | return fileWrite(source, srcInfo.Size(), destinationPath, privateFilePermission, srcInfo.ModTime()) |
| 209 | } |
| 210 | |
| 211 | // fileWrite performs a simple write to the destination file from the provided io.Reader. |
| 212 | // This in itself is not safe. |
no test coverage detected
searching dependent graphs…