Fix file content change handling and improve log messages
- Delete old file_chunks and chunk_files when file content changes - Add DeleteByFileID method to ChunkFileRepository - Add tests to verify old chunks are properly disassociated - Make log messages more precise throughout scanner and snapshot - Support metadata-only snapshots when no files have changed - Add periodic status output during scan and snapshot operations - Improve scan summary output with clearer information
This commit is contained in:
@@ -278,7 +278,7 @@ func (p *Packer) startNewBlob() error {
|
||||
size: 0,
|
||||
}
|
||||
|
||||
log.Debug("Started new blob", "blob_id", blobID, "temp_file", tempFile.Name())
|
||||
log.Debug("Created new blob container", "blob_id", blobID, "temp_file", tempFile.Name())
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ func (p *Packer) startNewBlob() error {
|
||||
func (p *Packer) addChunkToCurrentBlob(chunk *ChunkRef) error {
|
||||
// Skip if chunk already in current blob
|
||||
if p.currentBlob.chunkSet[chunk.Hash] {
|
||||
log.Debug("Skipping duplicate chunk in blob", "chunk_hash", chunk.Hash)
|
||||
log.Debug("Skipping duplicate chunk already in current blob", "chunk_hash", chunk.Hash)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ func (p *Packer) addChunkToCurrentBlob(chunk *ChunkRef) error {
|
||||
return p.repos.BlobChunks.Create(ctx, tx, blobChunk)
|
||||
})
|
||||
if err != nil {
|
||||
log.Error("Failed to store blob-chunk association", "error", err,
|
||||
log.Error("Failed to store blob-chunk association in database", "error", err,
|
||||
"blob_id", p.currentBlob.id, "chunk_hash", chunk.Hash)
|
||||
// Continue anyway - we can reconstruct this later if needed
|
||||
}
|
||||
@@ -329,7 +329,7 @@ func (p *Packer) addChunkToCurrentBlob(chunk *ChunkRef) error {
|
||||
// Update total size
|
||||
p.currentBlob.size += chunkSize
|
||||
|
||||
log.Debug("Added chunk to blob",
|
||||
log.Debug("Added chunk to blob container",
|
||||
"blob_id", p.currentBlob.id,
|
||||
"chunk_hash", chunk.Hash,
|
||||
"chunk_size", len(chunk.Data),
|
||||
@@ -410,7 +410,7 @@ func (p *Packer) finalizeCurrentBlob() error {
|
||||
}
|
||||
|
||||
compressionRatio := float64(finished.Compressed) / float64(finished.Uncompressed)
|
||||
log.Info("Finalized blob",
|
||||
log.Info("Finalized blob (compressed and encrypted)",
|
||||
"hash", blobHash,
|
||||
"chunks", len(chunkRefs),
|
||||
"uncompressed", finished.Uncompressed,
|
||||
@@ -420,7 +420,7 @@ func (p *Packer) finalizeCurrentBlob() error {
|
||||
|
||||
// Call blob handler if set
|
||||
if p.blobHandler != nil {
|
||||
log.Debug("Calling blob handler", "blob_hash", blobHash[:8]+"...")
|
||||
log.Debug("Invoking blob handler callback", "blob_hash", blobHash[:8]+"...")
|
||||
// Reset file position for handler
|
||||
if _, err := p.currentBlob.tempFile.Seek(0, io.SeekStart); err != nil {
|
||||
p.cleanupTempFile()
|
||||
@@ -441,7 +441,7 @@ func (p *Packer) finalizeCurrentBlob() error {
|
||||
// Note: blob handler is responsible for closing/cleaning up temp file
|
||||
p.currentBlob = nil
|
||||
} else {
|
||||
log.Debug("No blob handler set", "blob_hash", blobHash[:8]+"...")
|
||||
log.Debug("No blob handler callback configured", "blob_hash", blobHash[:8]+"...")
|
||||
// No handler, need to read data for legacy behavior
|
||||
if _, err := p.currentBlob.tempFile.Seek(0, io.SeekStart); err != nil {
|
||||
p.cleanupTempFile()
|
||||
|
||||
Reference in New Issue
Block a user