rejetto forum

Software => HFS ~ HTTP File Server => Bug reports => Topic started by: Kiego on May 13, 2021, 08:51:58 AM

Title: Unable to archive/download all
Post by: Kiego on May 13, 2021, 08:51:58 AM
Hi,

I am using the HFS version 2.3m build#300. I have a folder with many text files which are constantly have data appending to the files by other application. When I try to select multiple of these files and press archive from my Chrome browser. Not all the files selected are archived in my .tar file. I had tried other browser and the result is the same. Is there anyway I am able to have all the files selection to be archived in my .tar file?
Title: Re: Unable to archive/download all
Post by: NaitLee on May 13, 2021, 02:44:53 PM
In an operating system, when a file is opened and changing, other programs cannot see changes, or cannot even access it.
I've successfully reproduced this, with 10 files, only 4 in archive, and their contents are all \x00.
Maybe it's the file just got "immutable" when writing. (I'm not a low-level os expert)

So the solution is, keep the files closed when trying to access (archive) them.
You can try to close your file-writing applications, locally or remotely.
With HFS, you can do with macros. Be sure to keep secure.

P.S. What I've tried is following python code:
Code: [Select]
files = []
for i in range(10):
    files.append(open(str(i) + '.txt', 'w', encoding='utf-8'))
while True:
    for i in files:
        i.seek(0)
        i.write('1')
It infinitely writes the file on the first byte (char) until Ctrl+C.
Title: Re: Unable to archive/download all
Post by: Kiego on May 24, 2021, 09:24:12 AM
Hi, I tried to close the application (which is writing to file) and I managed to archive all the files. However my operation use is that the data that is coming in are live data which needs to be recorded at all times. If I stop my application, I will will have data loss during the process of archiving. Is there any other way that I can still archive the files with my application running?
Title: Re: Unable to archive/download all
Post by: danny on May 24, 2021, 03:18:39 PM
You can use the .exec macro to run a batch file, which creates copies or archives. 

batch command for multi-tasking is in this format (so the program doesn't wait until the command finishes)
start "" "program.exe" -o options

In this case, program.exe is your choice of copy or command line zip utility.
For an example of batch file, see my WatchCat script (signature link)
Title: Re: Unable to archive/download all
Post by: LeoNeeson on May 25, 2021, 04:46:03 AM
Hi Kiego. I've haven't tested, but to copy 'locked' or 'in use' files, you could try Hobocopy (http://candera.github.io/hobocopy/) or RawCopy (https://github.com/jschicht/RawCopy). Here (https://www.howtogeek.com/howto/windows-vista/backupcopy-files-that-are-in-use-or-locked-in-windows/) you will find a 'how-to' tutorial for Hobocopy, and more similar tools here (https://www.raymond.cc/blog/copy-locked-file-in-use-with-hobocopy/). To call hobocopy from HFS, you will find macro exec usage here (https://www.rejetto.com/wiki/index.php/HFS:_scripting_commands).
Title: Re: Unable to archive/download all
Post by: Kiego on July 06, 2021, 02:03:04 AM
While trying to use the Macros we found something else. Eg I have the following files:
File1.txt, file2.txt, file3.txt, file4.txt  where file3.txt are constantly writing.
When I select all and press archive, I can only see file1-3.txt but not file4.txt. The content within file3.txt is based on the timing I press my archive button. It seemed like after the remaining files are "discarded" after the constantly writing file.

When I try to extract the tar file using 7zip. I see the following in the properties:
Errors: Header Error
Warnings: There are some data after the end of the payload data.

Would like to ask if other than using RawCopy is there any other ways to prevent the discarding of data while archiving?
Title: Re: Unable to archive/download all
Post by: LeoNeeson on August 03, 2021, 11:46:00 AM
When I select all and press archive, I can only see file1-3.txt but not file4.txt. The content within file3.txt is based on the timing I press my archive button. It seemed like after the remaining files are "discarded" after the constantly writing file.
I guess HFS should ignore that file and continue, instead of aborting the 'archive' process (I don't know if this is easy to fix). As a start point, and doing a fast Google Search (http://www.google.com/search?q=Delphi+detect+files+being+used&hl=en), (https://stackoverflow.com/questions/502996/delphi-check-whether-file-is-in-use) I've found an interesting code, HERE (https://www.swissdelphicenter.ch/en/showcode.php?id=104).
Title: Re: Unable to archive/download all
Post by: LeoNeeson on August 24, 2021, 06:32:06 AM
Have you solved this issue? (Have you found a way to copy files being used?). Because I've found an easier way to do it, using 7-Zip. Instead of using HFS's archive function, you can macro call 7-Zip using the -ssw (https://info.nrao.edu/computing/guide/file-access-and-archiving/7zip/7z-7za-command-line-guide) switch (which compress files open for writing). You can even make a .bat (batch) file which does the 7-Zip archive process, and then simply call that batch (.bat) using a HFS's macro (exec). Please tell us, if you need more help...
Title: Re: Unable to archive/download all
Post by: upsidedown on December 18, 2021, 05:45:14 AM
Please tell us, if you need more help...

Hi, I would like this. I'm not having the same problem as OP but currently HFS can't archive folders only files, and I'm guessing that if I use 7-zip I would be able to, right?
Thanks.