Skip to content

Commit 7ee6c88

Browse files
dzackgarzaGPT-5
andcommitted
fix: release v3.2.2 for bytes temp-file fallback
Why: The 3.2.1 add-on still fails the live `upload_pdf` proof after the bytes fallback is selected. The add-on reports `OS is not defined`, which means the fallback path itself is crashing before Zotero can import the materialized PDF. Changes: - Replace `OS.Path.join` usage in the bytes materialization helper with the temp file object returned by `Zotero.getTempDirectory()`. - Replace `OS.File.remove` cleanup with `Zotero.File.pathToFile(...).remove(false)` so the fallback path stays within APIs available in the add-on runtime. - Bump the release metadata to 3.2.2 and regenerate `updates.json` for the new GitHub release asset. Decisions: - Kept the fix minimal and isolated to the bytes fallback path because the attach-by-path route and the new 3.2.1 contract were otherwise correct. - Released another patch version because this is a runtime compatibility fix, not a new endpoint or behavior line. Expected outcome: After updating to v3.2.2, the add-on should stop throwing `OS is not defined`, allowing the client-side bytes fallback to complete the stored PDF attachment path. Co-Authored-By: GPT-5 <noreply@google.com>
1 parent 530ef17 commit 7ee6c88

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.1
1+
3.2.2

src/bootstrap.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,14 @@ function isMissingFileError(error: unknown): boolean {
199199
async function materializeUploadBytes(fileName: string, fileBytesBase64: string): Promise<string> {
200200
const tempDir = Zotero.getTempDirectory();
201201
const safeFileName = Zotero.File.getValidFileName(fileName.trim()) || "attachment.bin";
202-
const tempPath = OS.Path.join(
203-
tempDir.path,
204-
`local-write-api-${Date.now()}-${Math.random().toString(16).slice(2)}-${safeFileName}`,
205-
);
202+
tempDir.append(`local-write-api-${Date.now()}-${Math.random().toString(16).slice(2)}-${safeFileName}`);
206203
const binary = atob(fileBytesBase64);
207204
const bytes = new Uint8Array(binary.length);
208205
for (let index = 0; index < binary.length; index++) {
209206
bytes[index] = binary.charCodeAt(index);
210207
}
211-
await Zotero.File.putContentsAsync(tempPath, bytes.buffer);
212-
return tempPath;
208+
await Zotero.File.putContentsAsync(tempDir.path, bytes.buffer);
209+
return tempDir.path;
213210
}
214211

215212
async function importStoredAttachment(parentItem: Zotero.Item, filePath: string, title: string): Promise<Zotero.Item> {
@@ -273,7 +270,7 @@ async function handleFulltextAttach(data: RequestData): Promise<JsonPayload> {
273270
finally {
274271
if (tempPath) {
275272
try {
276-
await OS.File.remove(tempPath);
273+
Zotero.File.pathToFile(tempPath).remove(false);
277274
}
278275
catch (error) {
279276
Zotero.logError(error instanceof Error ? error : new Error(String(error)));

updates.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"strict_min_version": "7.0"
1010
}
1111
},
12-
"update_hash": "sha256:40f533ff6f341c355febcb6298eef73ed42be2bb10cbe5efe6f35b180a20dff8",
13-
"update_link": "https://github.com/dzackgarza/zotero-local-write-api/releases/download/v3.2.1/local-write-api-3.2.1.xpi",
14-
"version": "3.2.1"
12+
"update_hash": "sha256:7c21015dd751c55d791d236c487600fe99f59110b6eb518f9564814dbd1acd5b",
13+
"update_link": "https://github.com/dzackgarza/zotero-local-write-api/releases/download/v3.2.2/local-write-api-3.2.2.xpi",
14+
"version": "3.2.2"
1515
}
1616
]
1717
}

0 commit comments

Comments
 (0)