rejetto forum

Software => HFS ~ HTTP File Server => Bug reports => Topic started by: skb on February 03, 2015, 10:09:20 AM

Title: 2.3d (292) : hfs.tpl :Delete after Archive repeats the archive download : FIXED
Post by: skb on February 03, 2015, 10:09:20 AM
After selecting and archiving some files, if you try to delete that set of files, you get the delete prompt, but the action that happens is a second archive download.

To reproduce, go to a folder with some files, where you have delete privileges. (Bug occurs either with a user with delete rights, or else with "anyone" can delete.) Select one or more files and click the "Archive" button, and download the .tar file.

Then, with the same files selected, click "Delete". After the prompt, the "archive" file save prompt is shown again, rather than the files being deleted.

In fact, even if you change the selection, all attempts to delete are instead seem to give archive prompts.

To clear this, navigate back to home, and then return to the folder. Now selecting files and deleting works.

After I first found this bug with my system, I re-tested it with a clean download and all settings reset and a new VFS.

I'm running Win8.1 64-bit. Bug happens with both Chrome and Firefox.
Title: Re: 2.3d (292) : hfs.tpl :Delete after Archive repeats the archive download again :
Post by: skb on February 04, 2015, 05:23:20 AM
Seems the bug is in the stock hfs.tpl

I tested using RAWR Designs' excellent "Live" template, and this confirmed that my bug is in the default hfs.tpl only, not intrinsic to the in the hfs server code.

I was hoping to find a simple example of the working logic for archives and deleting, but unfortunately the Live template is well beyond me; I could not even find their archiving and deleting code to compare it to the stock hfs.tpl version.

And, I while I haven't tried all of them yet, it seems most of the templates don't include the file-select-and-delete action. (Or, if they have it, I couldn't figure out how to access it as a logged-in user.)

The test case is: select some files, download an archvie, and then delete them. This works flawlessly and also mysteriously and incomprehensibly in RAWR's Live template; and yet it fails on a clean install of the base hfs.tpl . (And, honestly, I can't really understand it well enough to debug it there, either!)

I'm using HFS to host an Android-based data collection system, so it is all about the devices doing very simple .CSV input file downloads; and then simple uploads of the finished data files. These transfers are all one file at a time; archive .tar files are used only for loading the site with data for the collection tablets, and for fetching back the completed data files.

SO, the back office people will download a selected batch of uploaded data, and then delete these files from the server. So unfortunately, this possibly obscure "Download Archive, then Delete the files" bug is one that we'll step into all the time.

Are there other simple templates that allow selection and deletion that I can check for this bug?

Or, is there someone that can explain the archive and deletion code in either the stock hfs.tpl or in Live-3.0.1.tpl ?

Title: Re: 2.3d (292) : hfs.tpl :Delete after Archive repeats the archive download again :
Post by: bmartino1 on February 06, 2015, 02:11:40 AM
Hello Steve, and welcome to the Forum. This is more of an area to Rejeto. as he would be able to find the area to debug.

Glad that the RARW template is "working"( i think according to your post...

Live 3.1 TPL


under file configuration I think this is what you want

The spedcail strings:

curmodopt={.from table|moduleoptions|$1.}
modopt={.from table|opt.$1|$2.}
addnote={.set account|$1|notes key=$2=$3.}{.set account|$1|notes={.trim|{.get account|$1|notes.}.}.}
can mkdir={.get|can upload.}
can comment={.get|can upload.}
can rename={.get|can delete.}
can change password=member of|can change password


It would be easer to just keep using the Live template... and or PM Rejeto to look into this on the next build/update
Title: Re: 2.3d (292) : hfs.tpl :Delete after Archive repeats the archive download again :
Post by: skb on February 06, 2015, 06:55:14 AM
Thank you for your help. You're right, it would be much easier to just use the Live template! But, it is too complex for my simple application.

Reading through the forum, I found a post where Rejetto recommended the tool Fiddler ( to capture the actual POST requests from the browser to HFS. (Fiddler is really cool!)

With a clean stock hfs.tpl, I tried a delete, then an archive, and then then another delete, which shows the bug: The archive command adds ?mode=archive to the URL in the POST, and this doesn't get cleared out by the delete command. Delete adds "&action=delete" to the end of the selection list, but this is overridden by the ?mode.

Here are the key lines of the raw POSTs from fidder. First, the initial Delete, which works properly:
POST http://localhost/BUS/ HTTP/1.1

Next, an Archive of two files, which also works:
POST http://localhost/BUS/?mode=archive&recursive HTTP/1.1

Now try Delete on those same two files. This fails, and does another archive, because the "mode" string is still there:
POST http://localhost/BUS/?mode=archive&recursive HTTP/1.1

SO, the call to archive sets the mode, but the call to delete doesn't clear it.

Here's the post code for the Archive button (hfs.tpl line 201):
Code: [Select]
        <button id='archiveBtn' onclick='if (confirm("{.!confirm.}")) submit({}, "{.get|url|mode=archive|recursive.}")'>{.!Archive.}</button>
And the original code for the Delete button (hfs.tpl line 187):
Code: [Select]
        <button id='deleteBtn' onclick='if (confirm("{.!confirm.}")) submit({action:"delete"})'>{.!Delete.}</button>
The fix :) is to explicitly pass a URL with no mode string (REVISED hfs.tpl line 187): 
Code: [Select]
        <button id='deleteBtn' onclick='if (confirm("{.!confirm.}")) submit({action:"delete"}, "{.get|url.}")'>{.!Delete.}</button>
Title: Re: 2.3d (292) : hfs.tpl :Delete after Archive repeats the archive download : FIXED
Post by: rejetto on February 15, 2015, 02:45:39 PM
thank you very much skb, i will include this fix in the next release :)
Title: Re: 2.3d (292) : hfs.tpl :Delete after Archive repeats the archive download : FIXED
Post by: skb on February 21, 2015, 09:05:06 PM
Those pesky global variables; they get me every time.

Thanks for a very useful product!