mirror of
https://github.com/mitb-archive/filebot
synced 2025-03-10 06:20:27 -04:00
Update data files only if the contents have actually changed
This commit is contained in:
parent
d5c8551761
commit
34db5810df
@ -44,21 +44,32 @@ def osdb_out = dir_release.resolve('osdb.txt')
|
|||||||
|
|
||||||
|
|
||||||
def pack(file, lines) {
|
def pack(file, lines) {
|
||||||
|
def previousHash = hash(file)
|
||||||
|
|
||||||
file.withOutputStream{ out ->
|
file.withOutputStream{ out ->
|
||||||
out.withWriter('UTF-8'){ writer ->
|
out.withWriter('UTF-8'){ writer ->
|
||||||
lines.each{ writer.append(it).append('\n') }
|
lines.each{ writer.append(it).append('\n') }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hash(file) != previousHash) {
|
||||||
file.parentFile.resolve(file.name + '.xz').withOutputStream{ out ->
|
file.parentFile.resolve(file.name + '.xz').withOutputStream{ out ->
|
||||||
new XZOutputStream(out, new LZMA2Options(LZMA2Options.PRESET_DEFAULT)).withWriter('UTF-8'){ writer ->
|
new XZOutputStream(out, new LZMA2Options(LZMA2Options.PRESET_DEFAULT)).withWriter('UTF-8'){ writer ->
|
||||||
lines.each{ writer.append(it).append('\n') }
|
lines.each{ writer.append(it).append('\n') }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log.warning "[NOT MODIFIED] $file [$previousHash]"
|
||||||
|
}
|
||||||
|
|
||||||
def rows = lines.size()
|
def rows = lines.size()
|
||||||
def columns = lines.collect{ it.split(/\t/).length }.max()
|
def columns = lines.collect{ it.split(/\t/).length }.max()
|
||||||
log.info "${file.canonicalFile} ($rows rows, $columns columns)"
|
log.info "${file.canonicalFile} ($rows rows, $columns columns)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def hash(file) {
|
||||||
|
return file.length()
|
||||||
|
}
|
||||||
|
|
||||||
def isValidMovieName(s) {
|
def isValidMovieName(s) {
|
||||||
return (s.normalizePunctuation().length() >= 4) || (s=~ /^[A-Z0-9]/ && s =~ /[\p{Alnum}]{3}/)
|
return (s.normalizePunctuation().length() >= 4) || (s=~ /^[A-Z0-9]/ && s =~ /[\p{Alnum}]{3}/)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user