Skip to content

Crash on cleanupFilesCache #48

@torrswanson

Description

@torrswanson

I'm noticing an illegal opperation and a crash happening on the latest current commit on main, 0be9d19

On this line:

filesCache.removeValue(forKey: key)

I noticed you are iterating over a collection and at the same time removing a value. That's a problem.

Quick fix is to iterate over a copy of the collection and remove the value from the original collection to avoid the crash.

let tempFilesCache = filesCache //because we want to remove a value, so we can't iterate and remove at the same time.
for (key, _) in tempFilesCache where key.path != directory && key.path.starts(with: directory) && !files.contains(where: { key.path.starts(with: $0.path.trimmingCharacters(in: AccountPath.slash)) }) {
    filesCache.removeValue(forKey: key)
    changed = true
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions