alfem/telegram-download-daemon

Remove unused (partial) files from the destination folder

Closed this issue · 5 comments

I know, this somewhat contradicts the idea of .partial in #28, but now when we have the status, I thought maybe we can download to a Temp folder, and move to the destination folder when the download completed?

The download destination folder can be shared with other programs, since it is our program output, so the .partial solution was good, but I think it is better to use a Temp folder.


Another option, I don't want to open another issue about that because I think if we implementing the Temp folder, we don't need it, is to add a clean command to remove the unhandled .partial files.

All my issues are because my system is unstable, so my daemon is sometimes restarting and lose its download processes.

alfem commented

Perhaps we could merge both behaviours. With a combination two command line parameters: "destination folder" and "temporary folder" we can solve these use cases:

  1. Temporary folder not specified or equal to Destination folder: current behaviour. Files are downloaded to Destination Folder (with the .partial ending) and renamed after completion.

  2. Temporary folder different to Destination Folder: Files are downloaded to Temporary Folder (with the .partial ending) and moved to the Destination folder after completion.

Actually, in #28, I had suggested temp directory (named partials in my text). So, I wouldn't exactly call it to be conflicting with #28. I'm ok with that approach too.
I was not in favour of sharing the temp directory, to avoid potential file name conflicts with other programs. But if we keep the suffix specific to this daemon (instead of genetic like partial), I think the conflicts can be minimised.

alfem commented

I have added a new parameter --temp to point at a temporary directory. I have also changed the suffix for partially downloaded files to ".tdd".

I think we cover all the cases with this, don't we?

Thanks!

Now just want the clean command. It is not so necessary, since when everything is almost good it will clean almost nothing.
But if my connection is bad, for example, this folder might get a lot of files.

alfem commented

Now just want the clean command. It is not so necessary, since when everything is almost good it will clean almost nothing.

Done!