🔥 Tremora del Terra: ultimate hmac-file-server fix – final push before the drop 💾🔐
This commit is contained in:
0
CLAMAV_LARGE_FILE_FIX.md
Normal file
0
CLAMAV_LARGE_FILE_FIX.md
Normal file
0
CLAMAV_SCANNING_FIX.md
Normal file
0
CLAMAV_SCANNING_FIX.md
Normal file
0
CLAMAV_SECURITY_CONFIG.md
Normal file
0
CLAMAV_SECURITY_CONFIG.md
Normal file
0
CLUSTER_RESTART_GUIDE.md
Normal file
0
CLUSTER_RESTART_GUIDE.md
Normal file
0
DEDUPLICATION_1GB_OPTIMIZATION.md
Normal file
0
DEDUPLICATION_1GB_OPTIMIZATION.md
Normal file
0
DOCUMENTATION_UPDATE_SUMMARY.md
Normal file
0
DOCUMENTATION_UPDATE_SUMMARY.md
Normal file
0
ENDLESS_ENCRYPTION_FIX.md
Normal file
0
ENDLESS_ENCRYPTION_FIX.md
Normal file
0
FINAL_STATUS_REPORT.md
Normal file
0
FINAL_STATUS_REPORT.md
Normal file
0
INSTALL.MD
Normal file
0
INSTALL.MD
Normal file
0
LARGE_FILE_UPLOAD_FIX.md
Normal file
0
LARGE_FILE_UPLOAD_FIX.md
Normal file
0
NETWORK_RESILIENCE_GUIDE.md
Normal file
0
NETWORK_RESILIENCE_GUIDE.md
Normal file
0
PERFORMANCE_OPTIMIZATION.md
Normal file
0
PERFORMANCE_OPTIMIZATION.md
Normal file
0
QUEUE_RESILIENCE_GUIDE.md
Normal file
0
QUEUE_RESILIENCE_GUIDE.md
Normal file
0
QUEUE_RESILIENCE_SUMMARY.md
Normal file
0
QUEUE_RESILIENCE_SUMMARY.md
Normal file
0
UNIVERSAL_LARGE_UPLOAD_FIX.md
Normal file
0
UNIVERSAL_LARGE_UPLOAD_FIX.md
Normal file
0
UPLOAD_COMPLETION_FIX.md
Normal file
0
UPLOAD_COMPLETION_FIX.md
Normal file
0
UPLOAD_PERFORMANCE_VERIFICATION.md
Normal file
0
UPLOAD_PERFORMANCE_VERIFICATION.md
Normal file
0
VIDEO_EXTENSION_FIX.md
Normal file
0
VIDEO_EXTENSION_FIX.md
Normal file
@ -105,6 +105,34 @@ func handleChunkedUpload(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
// Pre-upload deduplication check for chunked uploads
|
||||
if conf.Server.DeduplicationEnabled {
|
||||
finalPath := filepath.Join(conf.Server.StoragePath, filename)
|
||||
if existingFileInfo, err := os.Stat(finalPath); err == nil {
|
||||
// File already exists - return success immediately for deduplication hit
|
||||
duration := time.Since(startTime)
|
||||
uploadDuration.Observe(duration.Seconds())
|
||||
uploadsTotal.Inc()
|
||||
uploadSizeBytes.Observe(float64(existingFileInfo.Size()))
|
||||
filesDeduplicatedTotal.Inc()
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
response := map[string]interface{}{
|
||||
"success": true,
|
||||
"filename": filename,
|
||||
"size": existingFileInfo.Size(),
|
||||
"completed": true,
|
||||
"message": "File already exists (deduplication hit)",
|
||||
}
|
||||
writeJSONResponse(w, response)
|
||||
|
||||
log.Infof("Chunked upload deduplication hit: file %s already exists (%s), returning success immediately",
|
||||
filename, formatBytes(existingFileInfo.Size()))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Create new session
|
||||
clientIP := getClientIP(r)
|
||||
session := uploadSessionStore.CreateSession(filename, totalSize, clientIP)
|
||||
|
@ -1515,6 +1515,32 @@ func handleUpload(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
absFilename := filepath.Join(storagePath, filename)
|
||||
|
||||
// Pre-upload deduplication check: if file already exists and deduplication is enabled, return success immediately
|
||||
if conf.Server.DeduplicationEnabled {
|
||||
if existingFileInfo, err := os.Stat(absFilename); err == nil {
|
||||
// File already exists - return success immediately for deduplication hit
|
||||
duration := time.Since(startTime)
|
||||
uploadDuration.Observe(duration.Seconds())
|
||||
uploadsTotal.Inc()
|
||||
uploadSizeBytes.Observe(float64(existingFileInfo.Size()))
|
||||
filesDeduplicatedTotal.Inc()
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
response := map[string]interface{}{
|
||||
"success": true,
|
||||
"filename": filename,
|
||||
"size": existingFileInfo.Size(),
|
||||
"message": "File already exists (deduplication hit)",
|
||||
}
|
||||
json.NewEncoder(w).Encode(response)
|
||||
|
||||
log.Infof("Deduplication hit: file %s already exists (%s), returning success immediately",
|
||||
filename, formatBytes(existingFileInfo.Size()))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Create the file
|
||||
dst, err := os.Create(absFilename)
|
||||
if err != nil {
|
||||
@ -1752,6 +1778,32 @@ func handleV3Upload(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
absFilename := filepath.Join(storagePath, filename)
|
||||
|
||||
// Pre-upload deduplication check: if file already exists and deduplication is enabled, return success immediately
|
||||
if conf.Server.DeduplicationEnabled {
|
||||
if existingFileInfo, err := os.Stat(absFilename); err == nil {
|
||||
// File already exists - return success immediately for deduplication hit
|
||||
duration := time.Since(startTime)
|
||||
uploadDuration.Observe(duration.Seconds())
|
||||
uploadsTotal.Inc()
|
||||
uploadSizeBytes.Observe(float64(existingFileInfo.Size()))
|
||||
filesDeduplicatedTotal.Inc()
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
response := map[string]interface{}{
|
||||
"success": true,
|
||||
"filename": filename,
|
||||
"size": existingFileInfo.Size(),
|
||||
"message": "File already exists (deduplication hit)",
|
||||
}
|
||||
json.NewEncoder(w).Encode(response)
|
||||
|
||||
log.Infof("Deduplication hit: file %s already exists (%s), returning success immediately",
|
||||
filename, formatBytes(existingFileInfo.Size()))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Create the file
|
||||
dst, err := os.Create(absFilename)
|
||||
if err != nil {
|
||||
@ -1907,6 +1959,23 @@ func handleLegacyUpload(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Pre-upload deduplication check: if file already exists and deduplication is enabled, return success immediately
|
||||
if conf.Server.DeduplicationEnabled {
|
||||
if existingFileInfo, err := os.Stat(absFilename); err == nil {
|
||||
// File already exists - return success immediately for deduplication hit
|
||||
duration := time.Since(startTime)
|
||||
uploadDuration.Observe(duration.Seconds())
|
||||
uploadsTotal.Inc()
|
||||
uploadSizeBytes.Observe(float64(existingFileInfo.Size()))
|
||||
filesDeduplicatedTotal.Inc()
|
||||
|
||||
w.WriteHeader(http.StatusCreated) // 201 Created for legacy compatibility
|
||||
log.Infof("Deduplication hit: file %s already exists (%s), returning success immediately",
|
||||
filename, formatBytes(existingFileInfo.Size()))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Create the file
|
||||
dst, err := os.Create(absFilename)
|
||||
if err != nil {
|
||||
|
@ -5,7 +5,6 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
0
config-clean.toml
Normal file
0
config-clean.toml
Normal file
0
tests/README.md
Normal file
0
tests/README.md
Normal file
0
verify_xmpp_upload.sh
Normal file
0
verify_xmpp_upload.sh
Normal file
Reference in New Issue
Block a user