@byline/storage-local 3.17.1 → 3.19.0
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.
|
@@ -83,6 +83,41 @@ class LocalStorageProvider {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
+
async move(fromPath, toPath) {
|
|
87
|
+
const fromAbsolute = path.join(this.uploadDir, fromPath);
|
|
88
|
+
const toAbsolute = path.join(this.uploadDir, toPath);
|
|
89
|
+
// Ensure the target directory exists.
|
|
90
|
+
fs.mkdirSync(path.dirname(toAbsolute), { recursive: true });
|
|
91
|
+
try {
|
|
92
|
+
await fs.promises.rename(fromAbsolute, toAbsolute);
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
// `rename` fails with EXDEV when uploadDir spans filesystems (e.g. a
|
|
96
|
+
// mounted volume boundary). Fall back to copy + unlink.
|
|
97
|
+
if (err.code === 'EXDEV') {
|
|
98
|
+
await fs.promises.copyFile(fromAbsolute, toAbsolute);
|
|
99
|
+
await fs.promises.unlink(fromAbsolute);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
throw err;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
storageProvider: this.providerName,
|
|
107
|
+
storagePath: toPath,
|
|
108
|
+
storageUrl: this.getUrl(toPath),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
async exists(storagePath) {
|
|
112
|
+
const absolutePath = path.join(this.uploadDir, storagePath);
|
|
113
|
+
try {
|
|
114
|
+
await fs.promises.access(absolutePath, fs.constants.F_OK);
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
86
121
|
getUrl(storagePath) {
|
|
87
122
|
return `${this.baseUrl}/${storagePath}`;
|
|
88
123
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@byline/storage-local",
|
|
3
3
|
"private": false,
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
|
-
"version": "3.
|
|
5
|
+
"version": "3.19.0",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=20.9.0"
|
|
8
8
|
},
|
|
@@ -38,18 +38,18 @@
|
|
|
38
38
|
"dist"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"uuid": "^14.0.
|
|
42
|
-
"@byline/core": "3.
|
|
41
|
+
"uuid": "^14.0.1",
|
|
42
|
+
"@byline/core": "3.19.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@biomejs/biome": "2.
|
|
46
|
-
"@types/node": "^
|
|
45
|
+
"@biomejs/biome": "2.5.2",
|
|
46
|
+
"@types/node": "^26.1.0",
|
|
47
47
|
"chokidar": "^5.0.0",
|
|
48
48
|
"chokidar-cli": "^3.0.0",
|
|
49
49
|
"npm-run-all": "^4.1.5",
|
|
50
|
-
"tsc-alias": "^1.
|
|
51
|
-
"tsx": "^4.
|
|
52
|
-
"typescript": "
|
|
50
|
+
"tsc-alias": "^1.9.0",
|
|
51
|
+
"tsx": "^4.23.0",
|
|
52
|
+
"typescript": "^7.0.2"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|