]> Sergey Matveev's repositories - uploader.git/blobdiff - main.go
Raise copyright years
[uploader.git] / main.go
diff --git a/main.go b/main.go
index b5bd5f5069e49a0a58fed218635c418213efad05..e3740f9a2ebac73e13d4f5a84fff63d64aee3d79 100644 (file)
--- a/main.go
+++ b/main.go
@@ -1,6 +1,6 @@
 /*
 uploader -- simplest form file uploader
-Copyright (C) 2018-2020 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2018-2021 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -54,11 +54,10 @@ const (
 var (
        Index = template.Must(template.New("index").Parse(`<html>
 <head><title>Upload</title></head><body>
-<pre>
 Example command line usage:
-
-    $ curl -F file=@somedata.tar.gpg [-F comment="optional comment"] http://.../upload/
-    $ b2sum -a blake2b somedata.tar.gpg # to verify checksum
+<pre>
+$ curl -F file=@somedata.tar.gpg [-F comment="optional comment"] http://.../upload/
+$ b2sum -a blake2b somedata.tar.gpg # to verify checksum
 </pre>
 <form enctype="multipart/form-data" action="/upload/" method="post">
 <label for="file">File to upload:</label><br/>
@@ -134,7 +133,7 @@ func upload(w http.ResponseWriter, r *http.Request) {
        tai64n.FromTime(t, ts)
        tai := ts.Encode()[1:]
        fnOrig := p.FileName()
-       fd, err := os.OpenFile(tai+".part", os.O_WRONLY|os.O_CREATE, 0666)
+       fd, err := os.OpenFile(tai+".part", os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0666)
        if err != nil {
                log.Println(r.RemoteAddr, tai, fnOrig, err)
                return
@@ -199,9 +198,11 @@ func upload(w http.ResponseWriter, r *http.Request) {
 func main() {
        bind := flag.String("bind", "[::]:8086", "Address to bind to")
        conns := flag.Int("conns", 2, "Maximal number of connections")
-       NotifyFromAddr = flag.String("notify-from", "uploader@example.com", "Address notifications are send to")
-       NotifyToAddr = flag.String("notify-to", "", "Address notifications are send from")
+       NotifyFromAddr = flag.String("notify-from", "uploader@example.com", "Address notifications are sent to")
+       NotifyToAddr = flag.String("notify-to", "", "Address notifications are sent from")
        flag.Parse()
+       log.SetFlags(log.Lshortfile)
+       log.SetOutput(os.Stdout)
        if len(*NotifyFromAddr) == 0 && len(*NotifyToAddr) > 0 {
                log.Fatalln("notify-from address can not be empty, if notify-to is set")
        }