MCPcopy Create free account
hub / github.com/an0nfunc/ALHP / syncMarchs

Function syncMarchs

utils.go:384–444  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

382 default:
383 return dispKeep
384 }
385}
386
387// stateDisposition classifies a failure to read a package's state file. Only a
388// state file that is genuinely gone means the package was dropped upstream; EIO,
389// EACCES and the rest are transient and must not cost us the build.
390//
391// Keep the os.IsNotExist spelling. errors.Is(err, fs.ErrNotExist) unwraps the whole
392// chain, so once this predicate is reachable for a db error it would read a pgx dial
393// failure over a unix socket as "dropped upstream" and delete every waiting artifact.
394func stateDisposition(err error) disposition {
395 if os.IsNotExist(err) {
396 return dispDelete
397 }
398 return dispKeep
399}
400
401// Why an artifact could not be published, as the waitingUnmovable metric's reason
402// label. A pkgname no row can be attributed to and an unreadable state file need
403// different responses, so the gauge has to tell them apart.
404const (
405 keptReasonUnresolved = "unresolved"
406 keptReasonState = "state"
407)
408
409// discardPackage removes an artifact and its detached signature from the waiting dir.
410func discardPackage(file string) {
411 _ = os.Remove(file)
412 _ = os.Remove(file + ".sig")
413}
414
415// storeDebugPackage copies a debug artifact into the debug store, which is keyed by
416// march alone and holds packages that never get a db row of their own.
417func storeDebugPackage(pkg Package, march string) error {
418 if err := os.MkdirAll(filepath.Join(conf.Basedir.Debug, march), 0o755); err != nil {
419 return fmt.Errorf("unable to create folder for debug-packages: %w", err)
420 }
421
422 forPackage := strings.TrimSuffix(pkg.Name(), debugSuffix)
423 log.Debugf("[MOVE] found debug package for package %s: %s", forPackage, pkg.Name())
424
425 dest := filepath.Join(conf.Basedir.Debug, march, filepath.Base(string(pkg)))
426 if _, err := os.Stat(dest); err == nil {
427 log.Warningf("[MOVE] overwrite existing debug infos for %s: %s", forPackage, dest)
428 }
429 return Copy(string(pkg), dest)
430}
431
432func movePackagesLive(ctx context.Context, fullRepo string) error {
433 if _, err := os.Stat(filepath.Join(conf.Basedir.Work, waitingDir, fullRepo)); os.IsNotExist(err) {
434 return nil
435 } else if err != nil {
436 return err
437 }
438
439 march := strings.Join(strings.Split(fullRepo, "-")[1:], "-")
440 repo := dbpackage.Repository(strings.Split(fullRepo, "-")[0])
441

Callers 1

mainFunction · 0.85

Calls 4

setupMakepkgFunction · 0.85
FindFunction · 0.85
NameMethod · 0.80
repoWorkerMethod · 0.80

Tested by

no test coverage detected