Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions acquisition/acquisition.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ func New(path string) (*Acquisition, error) {
func (a *Acquisition) Complete() {
a.Completed = time.Now().UTC()

// Close the log file before cleanup
log.CloseFileLog()

if a.Collector != nil {
a.Collector.Clean()
}
Expand Down
4 changes: 4 additions & 0 deletions acquisition/secure.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ func (a *Acquisition) StoreSecurely() error {
if err != nil {
return fmt.Errorf("failed to delete the unencrypted compressed archive: %v", err)
}

// Close the log file before removing the acquisition directory
log.CloseFileLog()

err = os.RemoveAll(a.StoragePath)
if err != nil {
return fmt.Errorf("failed to delete the original unencrypted acquisition folder: %v", err)
Expand Down
7 changes: 6 additions & 1 deletion log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,15 @@ func EnableFileLog(level LEVEL, filePath string) error {
return nil
}

func DisableFileLog() {
func CloseFileLog() {
log.fd.Close()
log.fd = nil
log.fileName = ""
if log.fd != nil {
log.fd.Close()
log.fd = nil
log.fileName = ""
}
}

func Debug(v ...any) {
Expand Down