Make archive migration threaded

This commit is contained in:
Jan Eitzinger 2023-03-27 11:11:28 +02:00
parent a4a90074ee
commit ff8f013b56

View File

@ -207,42 +207,45 @@ func main() {
} }
for job := range ar.Iter() { for job := range ar.Iter() {
fmt.Printf("Job %d\n", job.JobID) // fmt.Printf("Job %d\n", job.JobID)
job := job
path := getPath(job, dstPath, "meta.json") go func() {
err = os.MkdirAll(filepath.Dir(path), 0750) path := getPath(job, dstPath, "meta.json")
if err != nil { err = os.MkdirAll(filepath.Dir(path), 0750)
log.Fatal(err) if err != nil {
} log.Fatal(err)
f, err := os.Create(path) }
if err != nil { f, err := os.Create(path)
log.Fatal(err) if err != nil {
} log.Fatal(err)
}
jmn := deepCopyJobMeta(job) jmn := deepCopyJobMeta(job)
if err = EncodeJobMeta(f, &jmn); err != nil { if err = EncodeJobMeta(f, &jmn); err != nil {
log.Fatal(err) log.Fatal(err)
} }
if err = f.Close(); err != nil { if err = f.Close(); err != nil {
log.Fatal(err) log.Fatal(err)
} }
f, err = os.Create(getPath(job, dstPath, "data.json")) f, err = os.Create(getPath(job, dstPath, "data.json"))
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
var jd *JobData var jd *JobData
jd, err = loadJobData(getPath(job, srcPath, "data.json")) jd, err = loadJobData(getPath(job, srcPath, "data.json"))
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
jdn := deepCopyJobData(jd) jdn := deepCopyJobData(jd)
if err := EncodeJobData(f, &jdn); err != nil { if err := EncodeJobData(f, &jdn); err != nil {
log.Fatal(err) log.Fatal(err)
} }
if err := f.Close(); err != nil { if err := f.Close(); err != nil {
log.Fatal(err) log.Fatal(err)
} }
}()
} }
} }