Skip to content

Second time fetched file is broken #413

@ulitiy

Description

@ulitiy

New Issue Checklist

Issue Description

If file is fetched two times (only with real URL), the actual file is replaced by a broken one.

That's the case even across multiple app launches, it puts some URL string inside the actual file. Probably some cache issue.

Steps to reproduce

    func testFetchFile() throws {
        guard let parseFileURL = URL(string: "https://artworkout-parse.nyc3.cdn.digitaloceanspaces.com/116112879a51dfe3ce5e34105a26aae9_autumn.pumpkin.svg") else {
            XCTFail("Should create URL")
            return
        }
        var parseFile = ParseFile(name: "d3a37aed0672a024595b766f97133615_logo.svg", cloudURL: parseFileURL)
        parseFile.url = parseFileURL

        let firstFile = try parseFile.fetch()
        let firstStr = try! String(contentsOf: firstFile.localURL!)
        let secondFile = try parseFile.fetch()
        let secondStr = try! String(contentsOf: secondFile.localURL!)
        XCTAssertEqual(firstStr, secondStr)
    }

Actual Outcome

</g>
</svg>
") is not equal to (""file:\/\/\/Users\/xxx\/Library\/Developer\/CoreSimulator\/Devices\/XXXX\/data\/Library\/Private%20Documents\/parse\/Downloads\/d3a37aed0672a024595b766f97133615_logo.svg"")
Test Case '-[ParseSwiftTests.ParseFileTests testFetchFile]' failed (1.831 seconds).
Test Suite 'ParseFileTests' failed at 2022-09-13 21:33:10.256.

Expected Outcome

Test passing

Environment

Version 4.13.0

Logs

n/a

Workaround

Force fetch without cache

let secondFile = try parseFile.fetch(options: [.cachePolicy(.reloadIgnoringLocalCacheData)])

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions