forked from filebot/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.groovy
More file actions
executable file
·32 lines (24 loc) · 781 Bytes
/
verify.groovy
File metadata and controls
executable file
·32 lines (24 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env filebot -script
def hashType = any{ _args.mode.toUpperCase() }{ 'CRC32' }
parallel(args.files.collect{ f ->
return {
def attr_hash = f.xattr[hashType]
def calc_hash = f.hash(hashType)
if (attr_hash) {
log.finest "$attr_hash $calc_hash $f"
// abort if a mismatch has been found
if (attr_hash != calc_hash) {
die "$hashType mismatch: $attr_hash does not match: $calc_hash $f"
}
} else {
// compute checksum if it cannot be read from xattr
log.warning "Set $hashType xattr: $calc_hash $f"
f.xattr[hashType] = calc_hash
f.xattr[hashType + '.mtime'] = f.lastModified() as String
// verify that xattr has been set correctly
if (f.xattr[hashType] != calc_hash) {
die "Failed to set $hashType xattr: $f"
}
}
}
})