import { all as e, call as r } from "redux-saga/effects"
import { getCoreBackend as t } from "../../../../backend"
import { apiCall as i } from "../../../../api/core"
import { taskErrorSaga as n } from "../../../error"
export function* fetchFileEntry(e, r) {
if (!e) return null
try {
const n = t(),
l = yield i(n.getFileEntry, r, { pointer: e })
if (!l) return null
const { httpLink: o, cleared: c, own: f, byteLength: p } = l
return { httpLink: o, cleared: c, own: f, byteLength: p }
} catch (e) {
return (yield n("fetchFileEntry", e), null)
}
}
export function* fetchFileEntryWithPreviews(t, i) {
const n = yield r(fetchFileEntry, t.pointer, i)
if (!n) return null
if (t.preview) {
const [l, o, c] = yield e([
r(fetchFileEntry, t.preview.small?.pointer, i),
r(fetchFileEntry, t.preview.medium?.pointer, i),
r(fetchFileEntry, t.preview.large?.pointer, i),
])
n.preview = { small: l, medium: o, large: c }
}
return n
}