You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As the Zip spec doesn’t forbid this case (I think), these Zip files are, in theory, okay. you might end up with multiple identical entries in the Zip, e.g. the exact same file name/path more than once in the same directory within the Zip. This is the case when multiple “from”'s are given which end up creating the same Filename at the same location within the resulting zip.
However, depending on how and where you try to extract them, you’ll end up with a whole slue or problems and errors.
however somewhere i think it might be handy when communicating between client and the server, if you know what you are doing, files can be generated from memory. Google drive for example allows many documents all named "Untitled Spreadsheet" or "Untitled Documents". As unique IDs were assigned to them on the server side, there was never a need to restrict the user like legacy file systems.
What would you say about loosing up this rule a bit and get rid of the duplicate rule, and put this responsibility upon the developer instead?
The text was updated successfully, but these errors were encountered:
jimmywarting
changed the title
Allow duplicate file names/entries?
Allow duplicate file names/entries when creating zip files?
Sep 11, 2019
Note that you won't be able to copy/paste this into your project because it has lines specific to my situation.
const zip = new JSZip()
const filenamesThusFar: string[] = []
await Promise.all(
downloads.map(async (download) => {
if (!download.data) return
try {
// JSZip bug: JSZip will replace/overwrite files with the same name, and there is no option to override this.
let name = download.name || v4()
let nameCounter = 0
filenamesThusFar.forEach((filename) => {
if (filename === name) nameCounter++
})
filenamesThusFar.push(name)
if (nameCounter) name = `${name}_${nameCounter}`
const extension = getExtensionFromType(download.data.type)
name = `${name}${extension || '.mp3'}`
zip.file(name, download.data)
} catch (error) {
console.error(error)
throw error
}
})
)
As the Zip spec doesn’t forbid this case (I think), these Zip files are, in theory, okay. you might end up with multiple identical entries in the Zip, e.g. the exact same file name/path more than once in the same directory within the Zip. This is the case when multiple “from”'s are given which end up creating the same Filename at the same location within the resulting zip.
However, depending on how and where you try to extract them, you’ll end up with a whole slue or problems and errors.
however somewhere i think it might be handy when communicating between client and the server, if you know what you are doing, files can be generated from memory. Google drive for example allows many documents all named "Untitled Spreadsheet" or "Untitled Documents". As unique IDs were assigned to them on the server side, there was never a need to restrict the user like legacy file systems.
What would you say about loosing up this rule a bit and get rid of the duplicate rule, and put this responsibility upon the developer instead?
The text was updated successfully, but these errors were encountered: