Пример #1
0
func (self CachedMd5Comparer) md5(local *drive.LocalFile) string {
	// See if file exist in cache
	cached, found := self.cache[local.AbsPath()]

	// If found and modification time and size has not changed, return cached md5
	if found && local.Modified().UnixNano() == cached.Modified && local.Size() == cached.Size {
		return cached.Md5
	}

	// Calculate new md5 sum
	md5 := md5sum(local.AbsPath())

	// Cache file info if file meets size criteria
	if local.Size() > MinCacheFileSize {
		self.cacheAdd(local, md5)
		self.persist()
	}

	return md5
}
Пример #2
0
func (self CachedMd5Comparer) cacheAdd(lf *drive.LocalFile, md5 string) {
	self.cache[lf.AbsPath()] = &CachedFileInfo{
		Size:     lf.Size(),
		Modified: lf.Modified().UnixNano(),
		Md5:      md5,
	}
}
Пример #3
0
func (self Md5Comparer) Changed(local *drive.LocalFile, remote *drive.RemoteFile) bool {
	return remote.Md5() != md5sum(local.AbsPath())
}