@miniflare/storage-file
Advanced tools
Comparing version 2.0.0-rc.2 to 2.0.0-rc.3
@@ -24,4 +24,4 @@ import { Clock } from '@miniflare/shared'; | ||
export declare type FileStorageErrorCode = "ERR_TRAVERSAL"; | ||
export declare type FileStorageErrorCode = "ERR_TRAVERSAL" | "ERR_NAMESPACE_KEY_CHILD"; | ||
export { } |
@@ -83,11 +83,17 @@ // packages/storage-file/src/index.ts | ||
return; | ||
const value = await readFile(filePath); | ||
if (value === void 0) | ||
return; | ||
const meta = await this.meta(filePath); | ||
return { | ||
value: viewToArray(value), | ||
expiration: meta.expiration, | ||
metadata: meta.metadata | ||
}; | ||
try { | ||
const value = await readFile(filePath); | ||
if (value === void 0) | ||
return; | ||
const meta = await this.meta(filePath); | ||
return { | ||
value: viewToArray(value), | ||
expiration: meta.expiration, | ||
metadata: meta.metadata | ||
}; | ||
} catch (e) { | ||
if (e.code === "ENOTDIR") | ||
return; | ||
throw e; | ||
} | ||
} | ||
@@ -99,3 +105,10 @@ async put(key, { value, expiration, metadata }) { | ||
} | ||
await writeFile(filePath, value); | ||
try { | ||
await writeFile(filePath, value); | ||
} catch (e) { | ||
if (e.code !== "EEXIST") | ||
throw e; | ||
throw new FileStorageError("ERR_NAMESPACE_KEY_CHILD", 'Cannot put key "' + key + `" as a parent namespace is also a key. | ||
This is a limitation of Miniflare's file-system storage. Please use in-memory/Redis storage instead, or change your key layout.`, e); | ||
} | ||
const metaFilePath = filePath + metaSuffix; | ||
@@ -112,5 +125,11 @@ if (expiration !== void 0 || metadata !== void 0 || sanitised) { | ||
return false; | ||
const existed = await deleteFile(filePath); | ||
await deleteFile(filePath + metaSuffix); | ||
return existed; | ||
try { | ||
const existed = await deleteFile(filePath); | ||
await deleteFile(filePath + metaSuffix); | ||
return existed; | ||
} catch (e) { | ||
if (e.code === "ENOTDIR") | ||
return false; | ||
throw e; | ||
} | ||
} | ||
@@ -117,0 +136,0 @@ async listAllMaybeExpired() { |
{ | ||
"name": "@miniflare/storage-file", | ||
"version": "2.0.0-rc.2", | ||
"version": "2.0.0-rc.3", | ||
"description": "File-system storage module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers", | ||
@@ -39,8 +39,8 @@ "keywords": [ | ||
"dependencies": { | ||
"@miniflare/shared": "2.0.0-rc.2", | ||
"@miniflare/storage-memory": "2.0.0-rc.2" | ||
"@miniflare/shared": "2.0.0-rc.3", | ||
"@miniflare/storage-memory": "2.0.0-rc.3" | ||
}, | ||
"devDependencies": { | ||
"@miniflare/shared-test": "2.0.0-rc.2" | ||
"@miniflare/shared-test": "2.0.0-rc.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9781
174
+ Added@miniflare/shared@2.0.0-rc.3(transitive)
+ Added@miniflare/storage-memory@2.0.0-rc.3(transitive)
- Removed@miniflare/shared@2.0.0-rc.2(transitive)
- Removed@miniflare/storage-memory@2.0.0-rc.2(transitive)
Updated@miniflare/shared@2.0.0-rc.3