document-drive 0.0.18 → 0.0.19

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-drive",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "license": "AGPL-3.0-only",
5
5
  "type": "module",
6
6
  "module": "./src/index.ts",
@@ -1,7 +1,13 @@
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, writeFileSync } from 'fs';
4
+ import {
5
+ existsSync,
6
+ mkdirSync,
7
+ readFileSync,
8
+ readdirSync,
9
+ writeFileSync
10
+ } from 'fs';
5
11
  import fs from 'fs/promises';
6
12
  import path from 'path';
7
13
  import sanitize from 'sanitize-filename';
@@ -46,7 +52,7 @@ export class FilesystemStorage implements IDriveStorage {
46
52
  async getDocuments(drive: string) {
47
53
  let files: Dirent[] = [];
48
54
  try {
49
- files = await fs.readdir(path.join(this.basePath, drive), {
55
+ files = readdirSync(path.join(this.basePath, drive), {
50
56
  withFileTypes: true
51
57
  });
52
58
  } catch (error) {
@@ -72,10 +78,9 @@ export class FilesystemStorage implements IDriveStorage {
72
78
 
73
79
  async getDocument(drive: string, id: string) {
74
80
  try {
75
- const content = await fs.readFile(
76
- this._buildDocumentPath(drive, id),
77
- { encoding: 'utf-8' }
78
- );
81
+ const content = readFileSync(this._buildDocumentPath(drive, id), {
82
+ encoding: 'utf-8'
83
+ });
79
84
  return JSON.parse(content);
80
85
  } catch (error) {
81
86
  console.error(error);
@@ -96,7 +101,7 @@ export class FilesystemStorage implements IDriveStorage {
96
101
  }
97
102
 
98
103
  async getDrives() {
99
- const files = await fs.readdir(this.drivesPath, {
104
+ const files = await readdirSync(this.drivesPath, {
100
105
  withFileTypes: true
101
106
  });
102
107
  const drives: string[] = [];