Add share link UI after upload

This commit is contained in:
2026-09-13 00:17:37 +02:00
parent da36645aaf
commit 505e4f472f
8 changed files with 211 additions and 47 deletions
+16
View File
@@ -5,6 +5,7 @@ import (
"flag"
"fmt"
"os"
"path/filepath"
"text/tabwriter"
"time"
@@ -73,6 +74,7 @@ func tokenCommand(args []string) error {
if err != nil {
return err
}
warnIfUnusedDataDir(dataDir, tokensPath)
switch sub {
case "add":
@@ -96,6 +98,20 @@ func tokenCommand(args []string) error {
}
}
// warnIfUnusedDataDir flags the most likely mistake with this command: pointing
// --data somewhere the server does not read, so a freshly minted token is never
// seen and every request comes back 401. A data directory the server has opened
// always has an objects/ subdirectory.
func warnIfUnusedDataDir(dataDir, tokensPath string) {
if _, err := os.Stat(filepath.Join(dataDir, "objects")); err == nil {
return
}
fmt.Fprintf(os.Stderr,
"note: %s has no objects/ directory, so no server has used it.\n"+
" Tokens written to %s are only read by a server started with --data %s\n\n",
dataDir, tokensPath, dataDir)
}
func tokenAdd(file *auth.File, name, maxSize, maxExpiry, defExpiry string, vanity, admin bool) error {
secret, err := store.NewSecret()
if err != nil {