mirror of
https://github.com/9001/copyparty.git
synced 2025-09-28 20:52:26 -06:00
unindent after mkdir(XDG_CONFIG_HOME)
This commit is contained in:
parent
35472557cb
commit
abffda5474
|
@ -196,42 +196,41 @@ def init_E(EE: EnvParams) -> None:
|
||||||
(unicode, "/tmp"),
|
(unicode, "/tmp"),
|
||||||
]
|
]
|
||||||
errs = []
|
errs = []
|
||||||
if True:
|
for npath, (pf, pa) in enumerate(paths):
|
||||||
for npath, (pf, pa) in enumerate(paths):
|
p = ""
|
||||||
p = ""
|
try:
|
||||||
try:
|
p = pf(pa)
|
||||||
p = pf(pa)
|
if not p or p.startswith("~"):
|
||||||
if not p or p.startswith("~"):
|
continue
|
||||||
continue
|
|
||||||
|
|
||||||
p = os.path.normpath(p)
|
p = os.path.normpath(p)
|
||||||
if os.path.isdir(p) and os.listdir(p):
|
if os.path.isdir(p) and os.listdir(p):
|
||||||
mkdir = False
|
mkdir = False
|
||||||
else:
|
else:
|
||||||
mkdir = True
|
mkdir = True
|
||||||
os.mkdir(p)
|
os.mkdir(p)
|
||||||
|
|
||||||
p = os.path.join(p, "copyparty")
|
p = os.path.join(p, "copyparty")
|
||||||
if not os.path.isdir(p):
|
if not os.path.isdir(p):
|
||||||
os.mkdir(p)
|
os.mkdir(p)
|
||||||
|
|
||||||
if npath > 1:
|
if npath > 1:
|
||||||
t = "Using %s/copyparty [%s] for config; filekeys/dirkeys will change on every restart. Consider setting XDG_CONFIG_HOME or giving the unix-user a ~/.config/"
|
t = "Using %s/copyparty [%s] for config; filekeys/dirkeys will change on every restart. Consider setting XDG_CONFIG_HOME or giving the unix-user a ~/.config/"
|
||||||
errs.append(t % (pa, p))
|
errs.append(t % (pa, p))
|
||||||
elif mkdir:
|
elif mkdir:
|
||||||
t = "Using %s/copyparty [%s] for config%s (Warning: %s did not exist and was created just now)"
|
t = "Using %s/copyparty [%s] for config%s (Warning: %s did not exist and was created just now)"
|
||||||
errs.append(t % (pa, p, " instead" if npath else "", pa))
|
errs.append(t % (pa, p, " instead" if npath else "", pa))
|
||||||
elif errs:
|
elif errs:
|
||||||
errs.append("Using %s/copyparty [%s] instead" % (pa, p))
|
errs.append("Using %s/copyparty [%s] instead" % (pa, p))
|
||||||
|
|
||||||
if errs:
|
if errs:
|
||||||
warn(". ".join(errs))
|
warn(". ".join(errs))
|
||||||
|
|
||||||
return p # type: ignore
|
return p # type: ignore
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
if p and npath < 2:
|
if p and npath < 2:
|
||||||
t = "Unable to store config in %s [%s] due to %r"
|
t = "Unable to store config in %s [%s] due to %r"
|
||||||
errs.append(t % (pa, p, ex))
|
errs.append(t % (pa, p, ex))
|
||||||
|
|
||||||
raise Exception("could not find a writable path for config")
|
raise Exception("could not find a writable path for config")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue