| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Distinguish a destination this copy created from one another writer created.
The new short circuit removes the previous remove-before-copy step. FileManager.copyItem can fail after it creates the destination and writes part of the payload. The catch arm then finds the destination and reports success, so the report links a truncated attachment and the CLI still exits 0. The next export of the same name also short circuits at Line 64, so the truncated file is never repaired.
Record whether the destination existed before the copy, and delete a destination that only this failed copy created.
🛡️ Proposed guard for the failed-copy caseif FileManager.default.fileExists(atPath: destination.path) { return relativeURL.appendingPathComponent(resolved) } do { try FileManager.default.copyItem(at: source, to: destination) return relativeURL.appendingPathComponent(resolved) } catch { // A concurrent writer of the same payload can still beat us to the // creation; its bytes are our bytes, so losing that race is // success, not degradation. + // A destination this failed copy created itself is partial, not a + // rival's complete payload, so it must not be trusted. + if let sourceSize = try? FileManager.default + .attributesOfItem(atPath: source.path)[.size] as? Int, + let destinationSize = try? FileManager.default + .attributesOfItem(atPath: destination.path)[.size] as? Int, + sourceSize != destinationSize + { + try? FileManager.default.removeItem(at: destination) + }Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.