summaryrefslogtreecommitdiff
path: root/contrib/fs
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-10-09 08:56:16 -0600
committertjpcc <tjp@ctrl-c.club>2023-10-09 08:56:16 -0600
commit1a14f01df1c220f1b8a0dcee1eada007aca8d43f (patch)
treef445ec44eff7251c60c9d499c3514c5fba2c3340 /contrib/fs
parent0386be537b3e0e8097e30b0792589ad8b6819cba (diff)
contrib/fs.TitanUpload improvements
* use temporary gemini failure responses on errors * chmod created/updated files to 0644
Diffstat (limited to 'contrib/fs')
-rw-r--r--contrib/fs/gemini.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/contrib/fs/gemini.go b/contrib/fs/gemini.go
index d0ad2d8..1fb4e20 100644
--- a/contrib/fs/gemini.go
+++ b/contrib/fs/gemini.go
@@ -33,7 +33,11 @@ func TitanUpload(fsroot, urlroot string, approver tlsauth.Approver) sr.Middlewar
tmpf, err := os.CreateTemp("", "titan_upload_")
if err != nil {
- return gemini.PermanentFailure(err)
+ return gemini.Failure(err)
+ }
+
+ if err := os.Chmod(tmpf.Name(), 0644); err != nil {
+ return gemini.Failure(err)
}
if _, err := io.Copy(tmpf, body); err != nil {
@@ -48,7 +52,7 @@ func TitanUpload(fsroot, urlroot string, approver tlsauth.Approver) sr.Middlewar
filepath = path.Join(fsroot, filepath)
if err := os.Rename(tmpf.Name(), filepath); err != nil {
_ = os.Remove(tmpf.Name())
- return gemini.PermanentFailure(err)
+ return gemini.Failure(err)
}
return responder.Handle(ctx, request)