From 1a14f01df1c220f1b8a0dcee1eada007aca8d43f Mon Sep 17 00:00:00 2001 From: tjpcc Date: Mon, 9 Oct 2023 08:56:16 -0600 Subject: contrib/fs.TitanUpload improvements * use temporary gemini failure responses on errors * chmod created/updated files to 0644 --- contrib/fs/gemini.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'contrib/fs/gemini.go') 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) -- cgit v1.2.3