1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Changed export format extension to JEX and made it a non-compressed tar file

This commit is contained in:
Laurent Cozic
2018-02-25 21:08:32 +00:00
parent 9f8a46b9d9
commit 39ddd934f6
6 changed files with 119 additions and 39 deletions

View File

@ -1,7 +1,8 @@
const fs = require('fs-extra');
const { time } = require('lib/time-utils.js');
const FsDriverBase = require('lib/fs-driver-base');
class FsDriverNode {
class FsDriverNode extends FsDriverBase {
fsErrorToJsError_(error, path = null) {
let msg = error.toString();
@ -81,9 +82,14 @@ class FsDriverNode {
async stat(path) {
try {
const s = await fs.stat(path);
s.path = path;
return s;
const stat = await fs.stat(path);
return {
birthtime: stat.birthtime,
mtime: stat.mtime,
isDirectory: () => stat.isDirectory(),
path: path,
size: stat.size,
};
} catch (error) {
if (error.code == 'ENOENT') return null;
throw error;
@ -94,14 +100,20 @@ class FsDriverNode {
return fs.utimes(path, timestampDate, timestampDate);
}
async readDirStats(path) {
async readDirStats(path, options = null) {
if (!options) options = {};
if (!('recursive' in options)) options.recursive = false;
let items = await fs.readdir(path);
let output = [];
for (let i = 0; i < items.length; i++) {
let stat = await this.stat(path + '/' + items[i]);
const item = items[i];
let stat = await this.stat(path + '/' + item);
if (!stat) continue; // Has been deleted between the readdir() call and now
stat.path = stat.path.substr(path.length + 1);
output.push(stat);
output = await this.readDirStatsHandleRecursion_(path, stat, output, options);
}
return output;
}