summaryrefslogtreecommitdiff
path: root/utils/utils.go
diff options
context:
space:
mode:
authorJames Mills <prologic@shortcircuit.net.au>2020-03-29 17:41:10 +1000
committerJames Mills <prologic@shortcircuit.net.au>2020-03-29 17:41:10 +1000
commita22a2ae031f2c02b41aa9a7c1746b2989bcf0126 (patch)
tree8af65c4e69a6661e7554330f6d0d61c60bdde6f3 /utils/utils.go
parentb8aee1d2b5f09ae68f46e00f83eccff2dcf0bb55 (diff)
Add maximum upload size saftey and guards
Diffstat (limited to 'utils/utils.go')
-rw-r--r--utils/utils.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/utils/utils.go b/utils/utils.go
index 5293b0a..f80834c 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -7,9 +7,19 @@ import (
"net/http"
"os"
"os/exec"
+ "strconv"
"time"
)
+// SafeParseInt64 ...
+func SafeParseInt64(s string, d int64) int64 {
+ n, err := strconv.ParseInt(s, 10, 64)
+ if err != nil {
+ return d
+ }
+ return n
+}
+
func Download(url, filename string) error {
res, err := http.Get(url)
if err != nil {