Skip to content

Commit

Permalink
some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok committed Apr 11, 2024
1 parent dfadba2 commit b813b20
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/lib/media/manip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,17 @@ async function doResize(localUri: string, opts: DoResizeOpts): Promise<Image> {
},
)

// @ts-ignore This is valid, `getInfoAsync` will always return a size. The type is wonky
const info: FileInfo & {size: number} = await getInfoAsync(resizeRes.uri, {
const info: FileInfo = await getInfoAsync(resizeRes.uri, {
size: true,
})

// I'm not sure this can happen, but if we don't check `.exists`, then the `.size` type is undefined.
if (!info.exists) {
throw new Error(
'The image manipulation library failed to create a new image.',
)
}

// We want to clean up every resize _except_ the final result. We'll clean that one up later when we're finished
// with it
if (info.size < opts.maxSize) {
Expand Down Expand Up @@ -204,8 +210,7 @@ async function moveToPermanentPath(path: string, ext = ''): Promise<string> {
})

// This is just to try and clean up whenever we can. We won't always be able to, so in cases where we can't
// we just catch the error. We can't simply move some files though such as image caches, so we will copy then
// and attempt to clean up the original file
// we just catch the error.
// Paths that are image caches shouldn't be removed. com.hackemist.SDImageCache is used by SDWebImage and
// image_manager_disk_cache is used by Glide
if (
Expand Down

0 comments on commit b813b20

Please sign in to comment.