You've already forked AstralRinth
forked from didirus/AstralRinth
Remove the ability to replace uploaded primary versions (#1542)
This commit is contained in:
@@ -371,27 +371,9 @@
|
|||||||
:show-labels="false"
|
:show-labels="false"
|
||||||
:allow-empty="false"
|
:allow-empty="false"
|
||||||
/>
|
/>
|
||||||
<FileInput
|
|
||||||
v-if="isEditing && primaryFile.hashes.sha1 === file.hashes.sha1"
|
|
||||||
class="iconified-button raised-button"
|
|
||||||
prompt="Replace"
|
|
||||||
:accept="acceptFileFromProjectType(project.project_type)"
|
|
||||||
:max-size="524288000"
|
|
||||||
should-always-reset
|
|
||||||
@change="
|
|
||||||
(x) => {
|
|
||||||
deleteFiles.push(file.hashes.sha1)
|
|
||||||
version.files.splice(index, 1)
|
|
||||||
oldFileTypes.splice(index, 1)
|
|
||||||
|
|
||||||
replaceFile = x[0]
|
|
||||||
}
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<TransferIcon />
|
|
||||||
</FileInput>
|
|
||||||
<button
|
<button
|
||||||
v-else-if="isEditing"
|
v-else-if="isEditing"
|
||||||
|
:disabled="primaryFile.hashes.sha1 === file.hashes.sha1"
|
||||||
class="iconified-button raised-button"
|
class="iconified-button raised-button"
|
||||||
@click="
|
@click="
|
||||||
() => {
|
() => {
|
||||||
@@ -1056,19 +1038,7 @@ export default defineNuxtComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.replaceFile) {
|
if (this.newFiles.length > 0) {
|
||||||
const reader = new FileReader()
|
|
||||||
reader.onloadend = async function (event) {
|
|
||||||
const hash = await crypto.subtle.digest('SHA-1', event.target.result)
|
|
||||||
this.primaryFile.hashes.sha1 = [...new Uint8Array(hash)]
|
|
||||||
.map((x) => x.toString(16).padStart(2, '0'))
|
|
||||||
.join('')
|
|
||||||
}
|
|
||||||
|
|
||||||
reader.readAsArrayBuffer(this.replaceFile)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.newFiles.length > 0 || this.replaceFile) {
|
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
const fileParts = this.newFiles.map((f, idx) => `${f.name}-${idx}`)
|
const fileParts = this.newFiles.map((f, idx) => `${f.name}-${idx}`)
|
||||||
|
|
||||||
@@ -1089,14 +1059,6 @@ export default defineNuxtComponent({
|
|||||||
formData.append(fileParts[i], new Blob([this.newFiles[i]]), this.newFiles[i].name)
|
formData.append(fileParts[i], new Blob([this.newFiles[i]]), this.newFiles[i].name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.replaceFile) {
|
|
||||||
formData.append(
|
|
||||||
this.replaceFile.name.concat('-' + this.newFiles.length),
|
|
||||||
new Blob([this.replaceFile]),
|
|
||||||
this.replaceFile.name
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
await useBaseFetch(`version/${this.version.id}/file`, {
|
await useBaseFetch(`version/${this.version.id}/file`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData,
|
body: formData,
|
||||||
|
|||||||
Reference in New Issue
Block a user