aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2021-10-12 18:51:01 +0200
committerThomas Voss <mail@thomasvoss.com> 2021-10-12 18:51:01 +0200
commit113120aa32fb6eac38d396fee1ee9fc60006d8ac (patch)
tree854ba98d29fc33275dca0ef3d3df32a9bac11296
parent11a2560513e114ae30904f0598c4732aeac1972a (diff)
[mpaste] Bug fixes
-rw-r--r--mpaste.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/mpaste.go b/mpaste.go
index eec6a20..ade4b8e 100644
--- a/mpaste.go
+++ b/mpaste.go
@@ -178,6 +178,7 @@ func endpoint(w http.ResponseWriter, r *http.Request) {
}
mutex.Lock()
+ defer mutex.Unlock()
fname := file_prefix + strconv.Itoa(counter)
nfile, err := os.Create(fname)
@@ -198,7 +199,6 @@ func endpoint(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, domain+"/%d\n", counter)
counter++
- mutex.Unlock()
default:
WRITE_HEADER(http.StatusMethodNotAllowed, "Only GET and POST requests are supported")
}
@@ -233,6 +233,10 @@ func main() {
file_prefix += "/"
}
+ if counter_file == "" {
+ counter_file = "counter"
+ }
+
if index_file == "" {
index_file = "index.html"
}