mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-22 05:46:26 -08:00
uhhh idk
This commit is contained in:
parent
0621f55c20
commit
0a78c197a4
|
@ -184,7 +184,25 @@ export class UploadStream extends Writable {
|
||||||
if (!this.name) throw new WebError(400, "no filename provided")
|
if (!this.name) throw new WebError(400, "no filename provided")
|
||||||
if (!this.uploadId) this.setUploadId(generateFileId())
|
if (!this.uploadId) this.setUploadId(generateFileId())
|
||||||
|
|
||||||
// commit to db here...
|
let ogf = this.files.files[this.uploadId]
|
||||||
|
|
||||||
|
this.files.files[this.uploadId] = {
|
||||||
|
filename: this.name,
|
||||||
|
mime: this.mime,
|
||||||
|
messageids: this.messages,
|
||||||
|
owner: this.owner,
|
||||||
|
sizeInBytes: this.filled,
|
||||||
|
visibility: ogf ? ogf.visibility
|
||||||
|
: (
|
||||||
|
this.owner
|
||||||
|
? Accounts.getFromId(this.owner)?.defaultFileVisibility
|
||||||
|
: undefined
|
||||||
|
),
|
||||||
|
// so that json.stringify doesnt include tag:undefined
|
||||||
|
...((ogf||{}).tag ? {tag:ogf.tag} : {}),
|
||||||
|
|
||||||
|
chunkSize: this.files.config.maxDiscordFileSize
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// exposed methods
|
// exposed methods
|
||||||
|
@ -214,9 +232,13 @@ export class UploadStream extends Writable {
|
||||||
|| id.length > this.files.config.maxUploadIdLength)
|
|| id.length > this.files.config.maxUploadIdLength)
|
||||||
return this.destroy( new WebError(400, "invalid file ID") )
|
return this.destroy( new WebError(400, "invalid file ID") )
|
||||||
|
|
||||||
// There's more stuff to check here!
|
if (this.files.files[id] && this.files.files[id].owner != this.owner)
|
||||||
// Make sure to check if the upload ID is locked
|
return this.destroy( new WebError(403, "you don't own this file") )
|
||||||
// and if the user owns this file...
|
|
||||||
|
if (false /* check if locked here */)
|
||||||
|
return this.destroy( new WebError(409, "a file with this ID is already being uploaded") )
|
||||||
|
|
||||||
|
/* lock the id */
|
||||||
|
|
||||||
this.uploadId = id
|
this.uploadId = id
|
||||||
return this
|
return this
|
||||||
|
@ -232,7 +254,6 @@ export class UploadStream extends Writable {
|
||||||
|
|
||||||
private async startMessage(): Promise<Readable | undefined> {
|
private async startMessage(): Promise<Readable | undefined> {
|
||||||
|
|
||||||
|
|
||||||
if (!this.newmessage_debounce) return
|
if (!this.newmessage_debounce) return
|
||||||
this.newmessage_debounce = false
|
this.newmessage_debounce = false
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue