mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-10 19:31:39 +00:00
Merge branch 'master' into mf/rssInboundManager
This commit is contained in:
commit
c7b43bd94e
6 changed files with 681 additions and 0 deletions
|
|
@ -359,3 +359,22 @@ module.exports.encodeUriPath = (path) => {
|
|||
const uri = new URL(path, "file://")
|
||||
return uri.pathname
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if directory is writable.
|
||||
* This method is necessary because fs.access(directory, fs.constants.W_OK) does not work on Windows
|
||||
*
|
||||
* @param {string} directory
|
||||
* @returns {boolean}
|
||||
*/
|
||||
module.exports.isWritable = async (directory) => {
|
||||
try {
|
||||
const accessTestFile = path.join(directory, 'accessTest')
|
||||
await fs.writeFile(accessTestFile, '')
|
||||
await fs.remove(accessTestFile)
|
||||
return true
|
||||
} catch (err) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue