fix(api): сбросить кэши после восстановления базы
This commit is contained in:
1 parent
2943032462
commit
f1aac49dfc
18 files changed
+150
-17
No files matched your search
@@ -4,6 +4,7 @@ interface Dependencies {
|
||||
write:(path:string,buffer:Buffer)=>Promise<void>
|
||||
run:(args:string[])=>Promise<void>
|
||||
remove:(path:string)=>Promise<void>
|
||||
invalidate?:()=>void
|
||||
}
|
||||
export function validateSystemDatabaseRestoreArchive(buffer:Buffer):void{
|
||||
if(buffer.length>512*1024*1024)throw new Error("Файл бэкапа слишком большой")
|
||||
@@ -16,6 +17,7 @@ export async function executeSystemDatabaseRestore(buffer:Buffer,databaseUrl:str
|
||||
try{
|
||||
await deps.write(file,buffer)
|
||||
await deps.run(["--single-transaction","--clean","--if-exists","-d",databaseUrl,file])
|
||||
deps.invalidate?.()
|
||||
}catch(error){failed=true;failure=error}
|
||||
finally{try{await deps.remove(file)}catch{cleanupError="Не удалось удалить временный файл восстановления"}}
|
||||
if(failed){const message=failure instanceof Error?failure.message:"Восстановление PostgreSQL не подтверждено";throw new Error(message+(cleanupError?"; "+cleanupError:""))}
|
||||
|
||||
Reference in new issue
Block a user