Skip to content

Commit

Permalink
fix: character cloning not respecting empty uri
Browse files Browse the repository at this point in the history
  • Loading branch information
Vali-98 committed Oct 13, 2024
1 parent 21f6696 commit 7cc2017
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions app/constants/Characters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ export namespace Characters {
return undefined
}
})
if (image_id) await copyImage(imageuri, image_id)
if (image_id && imageuri) await copyImage(imageuri, image_id)
}

export const duplicateCard = async (charId: number) => {
Expand All @@ -480,11 +480,14 @@ export namespace Characters {
Logger.log('Failed to copy card: Card does not exit', true)
return
}
const cacheLoc = `${FS.cacheDirectory}${card.data.image_id}`
await FS.copyAsync({
from: getImageDir(card.data.image_id),
to: cacheLoc,
})
const imageInfo = await FS.getInfoAsync(getImageDir(card.data.image_id))

const cacheLoc = imageInfo.exists ? `${FS.cacheDirectory}${card.data.image_id}` : ''
if (imageInfo.exists)
await FS.copyAsync({
from: getImageDir(card.data.image_id),
to: cacheLoc,
})
const now = new Date().getTime()
card.data.last_modified = now
card.data.image_id = now
Expand Down

0 comments on commit 7cc2017

Please sign in to comment.