Skip to content

A crash will occur if the metadata of a saved audio file contains a "/". #2031

@enefry

Description

@enefry

crash in LegacyICloudFilePicker.swift >controller = DocumentPickerViewController(forExporting: [url], asCopy: true) while url is not exists !

in SaveMediaToFiles.swift > _ = try? FileManager.default.linkItem(atPath: data.path, toPath: symlinkPath) link. fail

why?

read info as file path from audio metadata, but some audio metadata contain '/' such as "abc/def" ,directory will not not create yet, so ,copy fail

nameComponents = ["abc/def","hello"]

            if !nameComponents.isEmpty {
                try? FileManager.default.removeItem(atPath: symlinkPath)
                
                let fileName = "\(nameComponents.joined(separator: " – ")).\(fileExtension)"  <---- abc/def-hello.mp3 
                symlinkPath = symlinkPath.replacingOccurrences(of: audioUrl.lastPathComponent, with: fileName) <--- xxxx/xxxx/abc/def-hello.mp3 
                let _ = try? FileManager.default.linkItem(atPath: data.path, toPath: symlinkPath) <--- directory not exists ! link fail
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions