mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 16:00:25 +08:00 
			
		
		
		
	Partial Content每次写入缓存时都检查Content-MD5是否一致
This commit is contained in:
		@@ -294,6 +294,10 @@ func (this *PartialFileWriter) IsNew() bool {
 | 
			
		||||
	return this.isNew && len(this.ranges.Ranges) == 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *PartialFileWriter) Ranges() *PartialRanges {
 | 
			
		||||
	return this.ranges
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *PartialFileWriter) remove() {
 | 
			
		||||
	_ = fsutils.Remove(this.rawWriter.Name())
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -355,6 +355,19 @@ func (this *HTTPWriter) PrepareCache(resp *http.Response, size int64) {
 | 
			
		||||
	}
 | 
			
		||||
	this.cacheWriter = cacheWriter
 | 
			
		||||
 | 
			
		||||
	// 对比Content-MD5
 | 
			
		||||
	{
 | 
			
		||||
		partialWriter, ok := cacheWriter.(*caches.PartialFileWriter)
 | 
			
		||||
		if ok {
 | 
			
		||||
			if partialWriter.Ranges().Version >= 2 && partialWriter.Ranges().ContentMD5 != this.Header().Get("Content-MD5") {
 | 
			
		||||
				_ = this.cacheWriter.Discard()
 | 
			
		||||
				this.cacheWriter = nil
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 判断是否新创建的缓存文件
 | 
			
		||||
	if this.isPartial {
 | 
			
		||||
		this.partialFileIsNew = cacheWriter.(*caches.PartialFileWriter).IsNew()
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user