Skip to content

Commit

Permalink
copy permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
et-nik committed Nov 13, 2023
1 parent 4fcc2bf commit a5182c2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/app/server/files/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,12 @@ func getFileFromClient(ctx context.Context, m anyMessage, readWriter io.ReadWrit
return writeError(readWriter, "Failed to transfer file")
}

err = copy.Copy(tmpFile.Name(), message.FilePath)
var permissions os.FileMode
if stat, err := os.Stat(message.FilePath); err == nil {
permissions = stat.Mode().Perm()
}

err = copy.Copy(tmpFile.Name(), message.FilePath, copy.Options{AddPermission: permissions})
if err != nil {
logger.Error(ctx, errors.WithMessage(err, "failed to copy tmp file"))
return writeError(readWriter, "Failed to copy tmp file")
Expand Down

0 comments on commit a5182c2

Please sign in to comment.