droppyjs / droppy

Self-hosted file storage
BSD 2-Clause "Simplified" License
104 stars 12 forks source link

fix paths #90

Closed vahtos closed 5 months ago

vahtos commented 5 months ago

Closes: #68

The requires syntax that was used in various modules is problematic because it stores the results of paths.get() at import time. This is probably best illustrated with an example:

const paths = require("./paths.js")
const paths2 = require("./paths.js").get();

paths.seed("/a/path/config", "/a/path/file")
console.log(paths.get().config); // <--- /a/path/config
console.log(paths2.config); // <--- !!! returns the default value: the results of resolve(os.homedir()), "/.droppy/config")
// because paths2 is set to the returned object of paths.get() at import time