local fileid
for file in self:file_iter() do
- hash.hash_append(hc, file:server())
- hash.hash_append(hc, file:location())
fileid, re = file:fileid()
if not fileid then
return false, e:cat(re)
info = e2tool.info()
- path, re = cache.fetch_file_path(info.cache, self:server(), self:location())
+ path, re = cache.fetch_file_path(info.cache, self:server(), self:location(), flags)
if not path then
return false, re
end
return fileid
end
---- Calculate the FileID for a file.
--- The name and location attributes are not included.
+--- Calculate the FileID for a file. This includes the checksum of the file
+-- as well as all set attributes.
-- @return FileID string: hash value, or false on error.
-- @return an error object on failure
function e2tool.file_class:fileid()
end
end
- return fileid
+ local hc, info
+ info = e2tool.info()
+ hc = hash.hash_start()
+ hash.hash_append(hc, self._server)
+ hash.hash_append(hc, self._location)
+
+ hash.hash_append(hc, fileid)
+
+ if self._licences then
+ local lid
+
+ for licencename in self._licences:iter() do
+ local lid, re = licence.licences[licencename]:licenceid(info)
+ if not lid then
+ return false, e:cat(re)
+ end
+ hash.hash_append(hc, lid)
+ end
+ end
+
+ if self._unpack then
+ hash.hash_append(hc, self._unpack)
+ elseif self._patch then
+ hash.hash_append(hc, self._patch)
+ elseif self._copy then
+ hash.hash_append(hc, self._copy)
+ end
+
+ return hash.hash_finish(hc)
end
--- Set or return the server attribute.
hash.hash_append(hc, self._name)
for file in self:file_iter() do
- hash.hash_append(hc, file:server())
- hash.hash_append(hc, file:location())
-
fileid, re = file:fileid()
if not fileid then
return false, e:cat(re)
return false, re
end
hash.hash_append(hc, fileid)
- hash.hash_append(hc, file:location())
- hash.hash_append(hc, file:server())
- if file:unpack() then
- hash.hash_append(hc, file:unpack())
- elseif file:patch() then
- hash.hash_append(hc, file:patch())
- elseif file:copy() then
- hash.hash_append(hc, file:copy())
- else
- assert(false, "no file attribute set")
- end
-
- -- per file licence list
- for licencename in file:licences():iter() do
- local lid, re = licence.licences[licencename]:licenceid(info)
- if not lid then
- return false, re
- end
- hash.hash_append(hc, lid)
- end
end
self._sourceid = hash.hash_finish(hc)