document-drive 0.0.17 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/storage/filesystem.ts +5 -11
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DocumentDriveDocument } from 'document-model-libs/document-drive';
|
|
2
2
|
import { Document } from 'document-model/document';
|
|
3
3
|
import type { Dirent } from 'fs';
|
|
4
|
-
import { existsSync, mkdirSync } from 'fs';
|
|
4
|
+
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
5
5
|
import fs from 'fs/promises';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import sanitize from 'sanitize-filename';
|
|
@@ -85,16 +85,10 @@ export class FilesystemStorage implements IDriveStorage {
|
|
|
85
85
|
|
|
86
86
|
async saveDocument(drive: string, id: string, document: Document) {
|
|
87
87
|
const documentPath = this._buildDocumentPath(drive, id);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
await fs.writeFile(handle, JSON.stringify(document), {
|
|
93
|
-
encoding: 'utf-8'
|
|
94
|
-
});
|
|
95
|
-
} finally {
|
|
96
|
-
await handle?.close();
|
|
97
|
-
}
|
|
88
|
+
await ensureDir(path.dirname(documentPath));
|
|
89
|
+
await writeFileSync(documentPath, JSON.stringify(document), {
|
|
90
|
+
encoding: 'utf-8'
|
|
91
|
+
});
|
|
98
92
|
}
|
|
99
93
|
|
|
100
94
|
async deleteDocument(drive: string, id: string) {
|