import{logger as a}from"../../../tools/notifiers/logger.js";import{convertFilterToWhereCondition as i}from"../../../providers/database/pagination/filter.js";import{createFileHashDbRecord as o}from"../mappers/create-file-hash-db-record.js";import{fileHashesTable as s}from"../../../providers/database/databases/main-sqlite/schemas/file-hashes-table.js";class d{#e;constructor(r){this.#e=r}async upsertFileHash(r){try{const e=o({...r});return await this.#e.client.insert(s).values(e).onConflictDoUpdate({target:[s.hash],set:{status:e.status,updatedAt:e.updatedAt}}),e.id}catch(e){return a.error("Error upserting file hash",e),null}}async updateFileHashes(r,e){try{const t=i(e);return t?(await this.#e.client.update(s).set({status:r}).where(t),!0):!1}catch(t){return a.error("Error updating file hashes",t),!1}}async deleteFileHashes(r){try{const e=i(r);return e?(await this.#e.client.delete(s).where(e),!0):!1}catch(e){return a.error("Error deleting file hashes",e),!1}}}export{d as FileHashesLocalWriteRepository};
