Author Topic: 2.3d (292) : hfs.tpl :Delete after Archive repeats the archive download : FIXED  (Read 3135 times)

0 Members and 1 Guest are viewing this topic.

Offline skb

  • Occasional poster
  • *
  • Posts: 43
    • View Profile
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.
« Last Edit: February 07, 2015, 04:34:07 AM by skb »

Offline skb

  • Occasional poster
  • *
  • Posts: 43
    • View Profile
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 ?

Thanks,
Steve

Offline bmartino1

  • Tireless poster
  • ****
  • Posts: 788
  • I'm only trying to help i mean no offense.
    • View Profile
    • none - google translate
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"(https://code.google.com/p/rawrmodulemod/downloads/list) i think according to your post...

Live 3.1 TPL
----

--------------

Code:(!NOT TESTED!)
under file configuration I think this is what you want

The spedcail strings:

[special:alias|private]
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.}.}.}
femodsection={.replace|$2|{:|:}|{.trim|{.$$1|file=$3.}.}.}
can mkdir={.get|can upload.}
can comment={.get|can upload.}
can rename={.get|can delete.}
can change password=member of|can change password

[Folder]
[link]
[file]

-----
It would be easer to just keep using the Live template... and or PM Rejeto to look into this on the next build/update
« Last Edit: February 06, 2015, 02:21:39 AM by bmartino1 »
I'm only trying to help i mean no offense.
thank you for your time and patience,
Bmartino1

Offline skb

  • Occasional poster
  • *
  • Posts: 43
    • View Profile
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 http://www.telerik.com/download/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:
Quote
POST http://localhost/BUS/ HTTP/1.1
   ...skipped...
selection=BUS_A60-Fishstick7&action=delete

Next, an Archive of two files, which also works:
Quote
POST http://localhost/BUS/?mode=archive&recursive HTTP/1.1
   ...skipped...
selection=BUS_A20-Shift_Hudson.txt&selection=BUS_A25-SF

Now try Delete on those same two files. This fails, and does another archive, because the "mode" string is still there:
Quote
POST http://localhost/BUS/?mode=archive&recursive HTTP/1.1
   ...skipped...
selection=BUS_A20-Shift_Hudson.txt&selection=BUS_A25-SF&action=delete

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>

Follow members gave a thank to your post:


Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12890
    • View Profile
thank you very much skb, i will include this fix in the next release :)

Offline skb

  • Occasional poster
  • *
  • Posts: 43
    • View Profile
Those pesky global variables; they get me every time.

Thanks for a very useful product!

Steve