Skip to content

Commit

Permalink
Fix some side effects wiping out URL data
Browse files Browse the repository at this point in the history
  • Loading branch information
slmnio committed Mar 9, 2023
1 parent 7bc5b69 commit 3058374
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/src/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ function getAutoFilename(attachment) {
async function removeAttachmentTimestamps(data) {
if (!data?.__tableName) return data;

data = JSON.parse(JSON.stringify(data));

let tableData = slmnggAttachments[data.__tableName];
if (tableData) {
tableData.forEach(key => {
Expand All @@ -162,7 +164,8 @@ async function removeAttachmentTimestamps(data) {
let { ending, filename } = getAutoFilename(attachment);
attachment._autoFilename = filename;
attachment.fileExtension = ending;
attachments.set(attachment.id, {...attachment});
attachments.set(attachment.id, JSON.parse(JSON.stringify(attachment)));
// console.log("att set", attachment, attachments.get(attachment.id));

// we don't want the URLs to appear in requests anymore
// the data server just uses the attachment IDs
Expand All @@ -173,6 +176,7 @@ async function removeAttachmentTimestamps(data) {
size = attachment.thumbnails[size];
size.url = null; // generateAttachmentURL(size.url, attachment);
}

});
}
});
Expand Down
2 changes: 2 additions & 0 deletions server/src/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ module.exports = ({ app, cors, Cache, corsHandle }) => {
// not already cached
console.log("[image]", `no file for ${filename} (${att.filename}) @ ${size}`);

if (!airtableURL) return res.status(404).send("No URL available for this image");

// first download or retrieve to orig/
let orig = await getOrWaitForDownload(airtableURL, filename, "orig");

Expand Down

0 comments on commit 3058374

Please sign in to comment.