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 t}from"../../../providers/database/databases/sqlite-db/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(t).values(e).onConflictDoUpdate({target:[t.fileType,t.filePath],set:{hash:e.hash,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 s=i(e);return s?(await this.#e.client.update(t).set({status:r}).where(s),!0):!1}catch(s){return a.error("Error updating file hashes",s),!1}}async deleteFileHashes(r){try{const e=i(r);return e?(await this.#e.client.delete(t).where(e),!0):!1}catch(e){return a.error("Error deleting file hashes",e),!1}}}export{d as FileHashesWriteRepository};
