mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-24 08:12:24 +02:00
Fixed OneDrive sync issue
This commit is contained in:
parent
45ac9daebe
commit
e89447dd85
@ -40,7 +40,7 @@ class FileApiDriverOneDrive {
|
||||
};
|
||||
}
|
||||
|
||||
async stat(path) {
|
||||
async statRaw_(path) {
|
||||
let item = null;
|
||||
try {
|
||||
item = await this.api_.execJson('GET', this.makePath_(path), this.itemFilter_());
|
||||
@ -48,6 +48,12 @@ class FileApiDriverOneDrive {
|
||||
if (error.error.code == 'itemNotFound') return null;
|
||||
throw error;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
async stat(path) {
|
||||
let item = await this.statRaw_(path);
|
||||
if (!item) return null;
|
||||
return this.makeItem_(item);
|
||||
}
|
||||
|
||||
@ -57,7 +63,8 @@ class FileApiDriverOneDrive {
|
||||
lastModifiedDateTime: moment.unix(timestamp / 1000).utc().format('YYYY-MM-DDTHH:mm:ss.SSS') + 'Z',
|
||||
}
|
||||
};
|
||||
await this.api_.exec('PATCH', this.makePath_(path), null, body);
|
||||
let item = await this.api_.execJson('PATCH', this.makePath_(path), null, body);
|
||||
return this.makeItem_(item);
|
||||
}
|
||||
|
||||
async list(path) {
|
||||
@ -101,12 +108,20 @@ class FileApiDriverOneDrive {
|
||||
}
|
||||
|
||||
async move(oldPath, newPath) {
|
||||
let previousItem = await this.statRaw_(oldPath);
|
||||
|
||||
let newDir = dirname(newPath);
|
||||
let newName = basename(newPath);
|
||||
|
||||
// We don't want the modification date to change when we move the file so retrieve it
|
||||
// now set it in the PATCH operation.
|
||||
|
||||
let item = await this.api_.execJson('PATCH', this.makePath_(oldPath), this.itemFilter_(), {
|
||||
name: newName,
|
||||
parentReference: { path: newDir },
|
||||
fileSystemInfo: {
|
||||
lastModifiedDateTime: previousItem.fileSystemInfo.lastModifiedDateTime,
|
||||
},
|
||||
});
|
||||
|
||||
return this.makeItem_(item);
|
||||
|
@ -52,8 +52,20 @@ class Logger {
|
||||
console[fn](line + object);
|
||||
}
|
||||
} else if (t.type == 'file') {
|
||||
if (typeof object === 'object') object = JSON.stringify(object);
|
||||
fs.appendFile(t.path, line + object + "\n", (error) => {
|
||||
let serializedObject = '';
|
||||
|
||||
if (typeof object === 'object') {
|
||||
if (object instanceof Error) {
|
||||
serializedObject = object.toString();
|
||||
if (object.stack) serializedObject += "\n" + object.stack;
|
||||
} else {
|
||||
serializedObject = JSON.stringify(object);
|
||||
}
|
||||
} else {
|
||||
serializedObject = object;
|
||||
}
|
||||
|
||||
fs.appendFile(t.path, line + serializedObject + "\n", (error) => {
|
||||
if (error) throw error;
|
||||
});
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ class Folder extends BaseItem {
|
||||
}
|
||||
|
||||
static loadNoteByField(folderId, field, value) {
|
||||
return this.modelSelectAll('SELECT * FROM notes WHERE is_conflict = 0 AND `parent_id` = ? AND `' + field + '` = ?', [folderId, value]);
|
||||
return this.modelSelectOne('SELECT * FROM notes WHERE is_conflict = 0 AND `parent_id` = ? AND `' + field + '` = ?', [folderId, value]);
|
||||
}
|
||||
|
||||
static async all(includeNotes = false) {
|
||||
|
@ -93,6 +93,7 @@ class Synchronizer {
|
||||
// Make the operation atomic by doing the work on a copy of the file
|
||||
// and then copying it back to the original location.
|
||||
let tempPath = this.syncDirName_ + '/' + path;
|
||||
|
||||
await this.api().put(tempPath, content);
|
||||
await this.api().setTimestamp(tempPath, local.updated_time);
|
||||
await this.api().move(tempPath, path);
|
||||
|
Loading…
Reference in New Issue
Block a user