add hint about systemd ReadWritePaths if hardlinking fails on linux due to cross-device link

may help admin figure out more easily how to work around this.

for issue #170 by rdelaage
This commit is contained in:
Mechiel Lukkien 2024-05-09 14:25:24 +02:00
parent 4d28a02621
commit 44a6927379
No known key found for this signature in database

View file

@ -10,7 +10,9 @@ import (
"log/slog"
"os"
"path/filepath"
"runtime"
"strings"
"syscall"
"time"
"github.com/mjl-/bstore"
@ -234,7 +236,11 @@ func backupctl(ctx context.Context, ctl *ctl) {
// No point in trying with regular copy, we would warn twice.
return false, err
} else if !warnedHardlink {
xwarnx("creating hardlink to message failed, will be doing regular file copies and not warn again", err, slog.String("srcpath", srcpath), slog.String("dstpath", dstpath))
var hardlinkHint string
if runtime.GOOS == "linux" && errors.Is(err, syscall.EXDEV) {
hardlinkHint = " (hint: if running under systemd, ReadWritePaths in mox.service may cause multiple mountpoints; consider merging paths into a single parent directory to prevent cross-device/mountpoint hardlinks)"
}
xwarnx("creating hardlink to message failed, will be doing regular file copies and not warn again"+hardlinkHint, err, slog.String("srcpath", srcpath), slog.String("dstpath", dstpath))
warnedHardlink = true
}