ID:1387364
 
BYOND Version:500
Operating System:Linux
Web Browser:Chrome 28.0.1500.71
Applies to:Dream Daemon
Status: Open

Issue hasn't been assigned a status value.
client/Topic(anything,href[])
if("Upload" in href)
var/mob/permitted/A=src.mob
if(!A.managing)
A.Manage_Files()
return
if(A.fileUpload)
A.Manage_Files()
return
A.fileUpload=1
var/list/T = list(".dmb",".rsc",".sav")
var/F = input("Select a file to upload.") as null|file
if(!F)
A.fileUpload=0
return
var/f="[F]"
var/Spot=findtext(f,".")
if(!Spot)
src<<"System could not detect file type in [f] or [F]." //Debugging line I added.
A.fileUpload=0
return
var/Path="Servers/[href["Upload"]]/[f]"
var/Ftype=copytext(f,Spot,length(f)+1)
if(Ftype==".zip")
src << "Disabled until fully functional."
return
if(!fcopy(F,Path))
src << "[f] failed to upload."
A.Auto_Manage_Files("[href["Upload"]]")
A.fileUpload=0
return
else
src << "[f] was uploaded successfully."
src << "Unzipping..."
shell("unzip '[Path]' -d 'Servers/[href["Upload"]]'")
src << "Deleting .zip file and all file types not in the allowed list..."
fdel(F)
A.ZipFileCheck("Servers/[href["Upload"]]/",T)
src << "Success!"
A.Auto_Manage_Files("[href["Upload"]]")
A.fileUpload=0
return
if(Ftype in T)
if(!fcopy(F,Path))
src << "[f] failed to upload."
A.Auto_Manage_Files("[href["Upload"]]")
A.fileUpload=0
return
else
src << "[f] was uploaded successfully."
A.Auto_Manage_Files("[href["Upload"]]")
A.fileUpload=0
return
else
src << "Invalid file type."
A.fileUpload=0
return


As I was testing out this code, I saw that when I uploaded a 0KB file (Empty) it did something strange. Instead of temporarily saving var/F, it instead kept the same thing. So, if I were to upload a 0KB "Testing" file, which would say "System could not detect.." in this case, and then upload a 0KB "Testing.dmb" file it would still be on "Testing". I guess if the two files match then it keeps their names the same. Sort of like saving memory and CPU.
src<<"System could not detect file type in [f] or [F]." Was my debug by the way.
The snippet is not complete, in that there are some vars here that aren't defined. Also I'm really not sure of what's going on here; the explanation of the bug isn't clear to me at all.

The only thing I do know is that this isn't a Dream Maker bug, because you're talking about runtime behavior. This would be a Dream Daemon bug.
Edited.
I'm still unclear on the exact nature of the bug. Can you describe in a little more detail what's going on?
When uploading a file that has no contents and then uploading another file that has no contents, they contain the same name. So, if a player wanted to upload a blank file (just for some odd reason such as creating the file for future use or editing) and then wanted to upload another blank file with a different name it would use the first blank file's name and not the newly uploaded one.
        if(Ftype in T)
if(!fcopy(F,Path))
src << "[f] failed to upload."
A.Auto_Manage_Files("[href["Upload"]]")
A.fileUpload=0
return
else
src << "[f] was uploaded successfully."
A.Auto_Manage_Files("[href["Upload"]]")
A.fileUpload=0
return


input -> f = File1.dmb (It has filetype .dmb, 0KB or no content)
output -> checks for Ftype and Ftype is now .dmb so..

src << "File1.dmb was uploaded successfully."

input -> f = File1.sav (It has a filetype .sav, 0KB or no content. I would suspect that it also works if both contents are the same. Not tested.)

output -> checks for Ftype and Ftype is now .dmb NOT .sav so..

src << "File1.dmb was uploaded successfully." when File1.sav was actually uploaded but not given its proper name.
Oh. I'm closing this as a non-bug, then. The 0-byte files are identical so the upload process just goes with the first name it gets. You'll have the exact same thing if you have two files with different names but the same content.
Lummox JR resolved issue (Not a bug)
I moved this to Feature Requests and produced a video to explain what is going on.

https://www.dropbox.com/s/jz2kuezx6a24k8j/Files.mp4?dl=0

Could this be changed (or have some workaround that doesn't mean editing the file type after every time a person uploads a file)? It also travels throughout other games too. So it's not just a single server.

It's starting to get a bit aggravating after so long. My presumption is a way, via code, to clear
I don't really follow what's happening in the video, so I'm not sure what you mean.
1. I uploaded savedAdmins.bdb
2. I realized it had to be a .sav file.
3. I renamed the file on my computer to .sav
4. I reuploaded savedAdmins.sav
5. It thinks it is still savedAdmins.bdb
Okay, so that's a non-zero file length? That does explain a bit. I'm not sure if a filename can be preserved in these cases, because once something's in the cache it keeps that original name.

So basically you're looking for a way that the dynamic cache can clear an entry or at least allow it to be renamed?
In response to Lummox JR
Lummox JR wrote:
Okay, so that's a non-zero file length?

Yes. The title was created before I realized it worked happened on non-zeros. Sorry for any confusion upon coming back to this topic.

So basically you're looking for a way that the dynamic cache can clear an entry or at least allow it to be renamed?

Yes.