Skip to content

Commit 451bb29

Browse files
committed
Fix handling of born-digital AIPs, fixes #90
- Update expected SIP paths for born-digital AIPs to include "additional/UpdatedAreldaMetadata.xml" and "content/header/old/SIP/ metadata.xml" files - Update verify_manifest activity to handle born-digital AIP manifests correctly - Add tests for all SFA SIP types
1 parent 4ac122f commit 451bb29

6 files changed

+293
-67
lines changed

internal/activities/add_premis_objects_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestAddPREMISObjects(t *testing.T) {
2424
fs.WithDir("xsd",
2525
fs.WithFile("arelda.xsd", ""),
2626
),
27-
fs.WithFile("metadata.xml", sipManifest),
27+
fs.WithFile("metadata.xml", digitizedSIPMetadata),
2828
),
2929
fs.WithDir("content",
3030
fs.WithDir("d_0000001",

internal/activities/verify_manifest.go

+14-6
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ func manifestFiles(s sip.SIP) (map[string]*manifest.File, error) {
8686
return nil, err
8787
}
8888

89-
// Prefix "content/" to digitized AIP file paths.
90-
if s.Type == enums.SIPTypeDigitizedAIP {
89+
// Prefix "content/" to AIP file paths.
90+
if isAIP(s.Type) {
9191
m := make(map[string]*manifest.File, len(files))
9292
for k, v := range files {
9393
m[filepath.Join("content", k)] = v
@@ -102,7 +102,7 @@ func manifestFiles(s sip.SIP) (map[string]*manifest.File, error) {
102102
// (excluding directory) paths found.
103103
func sipFiles(s sip.SIP) (goset.Set[string], error) {
104104
root := s.Path
105-
if s.Type == enums.SIPTypeDigitizedAIP {
105+
if isAIP(s.Type) {
106106
root = filepath.Join(s.Path, "content")
107107
}
108108

@@ -121,9 +121,9 @@ func sipFiles(s sip.SIP) (goset.Set[string], error) {
121121
return err
122122
}
123123

124-
// Digitized SIPs and born-digital SIPs don't include metadata.xml in
125-
// the manifest, so ignore the file here.
126-
if s.Type != enums.SIPTypeDigitizedAIP && p == "header/metadata.xml" {
124+
// SIPs don't include metadata.xml in the manifest, so ignore the file
125+
// here.
126+
if isSIP(s.Type) && p == "header/metadata.xml" {
127127
return nil
128128
}
129129

@@ -239,3 +239,11 @@ func generateHash(path, alg string) (string, error) {
239239

240240
return hex.EncodeToString(h.Sum(nil)), nil
241241
}
242+
243+
func isAIP(t enums.SIPType) bool {
244+
return t == enums.SIPTypeBornDigitalAIP || t == enums.SIPTypeDigitizedAIP
245+
}
246+
247+
func isSIP(t enums.SIPType) bool {
248+
return t == enums.SIPTypeBornDigitalSIP || t == enums.SIPTypeDigitizedSIP
249+
}

0 commit comments

Comments
 (0)