Fix migration script
It didn't even compile :(
This commit is contained in:
parent
78a66dc089
commit
9f5458c8f4
1 changed files with 10 additions and 9 deletions
|
@ -82,15 +82,17 @@ let copy_paths datadir (old_path, new_path) =
|
||||||
let old_path = Fpath.(datadir // v old_path) and new_path = Fpath.(datadir // v new_path) in
|
let old_path = Fpath.(datadir // v old_path) and new_path = Fpath.(datadir // v new_path) in
|
||||||
let new_path_tmp = Fpath.(new_path + "tmp") in
|
let new_path_tmp = Fpath.(new_path + "tmp") in
|
||||||
let* _created = Bos.OS.Dir.create (Fpath.parent new_path) in
|
let* _created = Bos.OS.Dir.create (Fpath.parent new_path) in
|
||||||
|
let cmd = Bos.Cmd.(v "cp" % p old_path % p new_path_tmp) in
|
||||||
let* () =
|
let* () =
|
||||||
Bos.OS.File.with_ic old_path
|
match Bos.OS.Cmd.run_status cmd with
|
||||||
(Bos.OS.File.with_oc new_path_tmp (fun oc ic ->
|
| Ok `Exited 0 ->
|
||||||
let buf = Bytes.create 4096 in
|
Ok ()
|
||||||
let rec loop () =
|
| Ok status ->
|
||||||
let len = input ic buf 0 4096 in
|
let _ = Bos.OS.Path.delete new_path_tmp in
|
||||||
if len > 0 then output oc buf 0 len
|
Error (`Msg (Fmt.str "cp failed: %a" Bos.OS.Cmd.pp_status status))
|
||||||
in
|
| Error _ as e ->
|
||||||
loop ()))
|
let _ = Bos.OS.Path.delete new_path_tmp in
|
||||||
|
e
|
||||||
in
|
in
|
||||||
Bos.OS.Path.move ~force:true new_path_tmp new_path
|
Bos.OS.Path.move ~force:true new_path_tmp new_path
|
||||||
|
|
||||||
|
@ -142,7 +144,6 @@ let fixup_rollback datadir (module Db : Caqti_blocking.CONNECTION) =
|
||||||
Db.iter_s old_build_artifact_paths
|
Db.iter_s old_build_artifact_paths
|
||||||
(fun (old_path, new_path) ->
|
(fun (old_path, new_path) ->
|
||||||
let* old_exists = Bos.OS.Path.exists Fpath.(datadir // v old_path) in
|
let* old_exists = Bos.OS.Path.exists Fpath.(datadir // v old_path) in
|
||||||
let* new_exists = Bos.OS.Path.exists Fpath.(datadir // v new_path) in
|
|
||||||
if old_exists then
|
if old_exists then
|
||||||
Bos.OS.Path.delete Fpath.(datadir // v new_path)
|
Bos.OS.Path.delete Fpath.(datadir // v new_path)
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue