You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-26 22:41:17 +02:00
Desktop, Cli: Replace note links with relative paths in MD Exporter (#2161)
* Replace linked Note ids by relative paths in MD Exporter. * Added tests for the MD Exporter. * Changed fs.readdirSync use for earlier Node version (v8) In the previous commit the code used fs.readdirSync from Node v10 or later. But since Joplin still uses v8, I changed the use of fs.readdirSync to be in line with the earlier api. * Updated readDirSync use for Node v10, which allows gets folder names too. * Revert "Updated readDirSync use for Node v10, which allows gets folder names too." This reverts commit 8f255db120861dd7773d99e1b63f4864d39594cf. Because the Travis builds still use Node v8. This is fine as well, the readdirSync returns the filenames in the directory. * Added reservedNames param to findUniqueFilename
This commit is contained in:
committed by
Laurent Cozic
parent
69f9e38730
commit
d9d75d6c71
@@ -21,7 +21,10 @@ class FsDriverBase {
|
||||
return output;
|
||||
}
|
||||
|
||||
async findUniqueFilename(name) {
|
||||
async findUniqueFilename(name, reservedNames = null) {
|
||||
if (reservedNames === null) {
|
||||
reservedNames = [];
|
||||
}
|
||||
let counter = 1;
|
||||
|
||||
let nameNoExt = filename(name, true);
|
||||
@@ -29,7 +32,8 @@ class FsDriverBase {
|
||||
if (extension) extension = `.${extension}`;
|
||||
let nameToTry = nameNoExt + extension;
|
||||
while (true) {
|
||||
const exists = await this.exists(nameToTry);
|
||||
// Check if the filename does not exist in the filesystem and is not reserved
|
||||
const exists = await this.exists(nameToTry) || reservedNames.includes(nameToTry);
|
||||
if (!exists) return nameToTry;
|
||||
nameToTry = `${nameNoExt} (${counter})${extension}`;
|
||||
counter++;
|
||||
|
||||
Reference in New Issue
Block a user