Skip to content

Corrupted log files due to in-place overwrite #45

Description

@dpusceddu

We are happy to answer your questions about the code or discuss technical ideas.

Please complete the following checklist (by adding [x]):

  • I have searched open and closed issues for duplicates
  • This isn't a feature request
  • This is not a report about my app not working as expected

My proton-drive.log log file is all weird and messed up. This is because the log writer starts at byte 0 and overwrites as it goes, without truncating the file or rotating it.

constructor(logDir: string) {
this.formatter = new BasicLogFormatter();
const logFile = path.join(logDir, 'proton-drive.log');
const file = Bun.file(logFile);
this.writer = file.writer();
}

Consequences:

  • The log file contains incomplete logs from many different runs, especially if the client has been used many times and with some old long runs
  • The file stays at the size of the largest run ever. My log file is currently permanently 89MB, most of it from a weeks-old run, but anyway it's unusable to get info about that run because the majority of it has been overwritten by newer runs

Truncating on open would at least keep the file recent, coherent and small. Even better, append with some size-based cap would additionally let a failed run's log (fully) survive the next invocation and make root-causing past problems that much easier

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions