daneren2005 / Subsonic

Home of the DSub Android client fork
GNU General Public License v3.0
578 stars 162 forks source link

Tweak cached filename format to facilitate manual caching #194

Closed p-ang closed 10 years ago

p-ang commented 10 years ago

I do appreciate that this may potentially represent a significant change, but I was wondering whether it would be possible to change the way that cached files are named in the cache. Currently they have a ".completed." tag just before their extension. I propose to drop that, use their original filename (or a preset format ie. %artist% - %title%) and instead retain such tags for files that are incomplete, etc.

If this is done it would be possible to use classical folder comparison tools to make sure that the cache folder is up-to-date with the server folder (ie. in case files have been deleted, tags changed, replaygain settings applied, etc etc).

trapexit commented 10 years ago

I'd agree labelling them as "completed" via the filename seems odd and unnecessary. A better idea may come from common ways to move files around. Download to a secret, temporary file and then rename it when it's ready. I'm not familiar with Android APIs but something like mktemp or mkstemp. The final name being in the same format as the original or perhaps some standard "artist - album - tracknumber - title.ext" format.

On Fri, Nov 22, 2013 at 4:40 AM, p-ang notifications@github.com wrote:

I do appreciate that this may potentially represent a significant change, but I was wondering whether it would be possible to change the way that cached files are named in the cache. Currently they have a ".completed." tag just before their extension. I propose to drop that, use their original filename (or a preset format ie. %artist% - %title%) and instead retain such tags for files that are incomplete, etc.

If this is done it would be possible to use classical folder comparison tools to make sure that the cache folder is up-to-date with the server folder (ie. in case files have been deleted, tags changed, replaygain settings applied, etc etc).

— Reply to this email directly or view it on GitHubhttps://github.com/daneren2005/Subsonic/issues/194 .

daneren2005 commented 10 years ago

I'm not really sure anything like this is necessary. While downloading the file it is called a .partial. When it is done it is renamed to a .complete. If you use the permanent cache (or pin for regular Subsonic), then it is renamed to just the normal file name. I think that is kind of backwards, since the pin one is the less used (I would have had the pin one be .saved), but either way all 3 are needed (though as bile pointed out, the .partial could easily be saved in a tmp folder instead). It is already possible to do comparisons, and if fact that is how the lists are being shown in the first place. It complicates matters that you have to check against .partial, .complete, and the standard file name, but all 3 are needed in some form or another.

If you are looking for this functionality for your other ticket, the service.DownloadFile class provides a nice wrapper for this functionality already, with methods for checking if each type of the file exists, or if any of them exist, or if only a complete file (standard or .complete) exist.

p-ang commented 10 years ago

Many thanks for this. I didn't know that permanent cache worked like that!

-------- Original message -------- From: daneren2005 notifications@github.com Date: 22/11/2013 20:47 (GMT+00:00) To: daneren2005/Subsonic Subsonic@noreply.github.com Cc: p-ang p@ngl.gr Subject: Re: [Subsonic] Tweak cached filename format to facilitate manual caching (#194)

I'm not really sure anything like this is necessary. While downloading the file it is called a .partial. When it is done it is renamed to a .complete. If you use the permanent cache (or pin for regular Subsonic), then it is renamed to just the normal file name. I think that is kind of backwards, since the pin one is the less used (I would have had the pin one be .saved), but either way all 3 are needed (though as bile pointed out, the .partial could easily be saved in a tmp folder instead). It is already possible to do comparisons, and if fact that is how the lists are being shown in the first place. It complicates matters that you have to check against .partial, .complete, and the standard file name, but all 3 are needed in some form or another.

If you are looking for this functionality for your other ticket, the service.DownloadFile class provides a nice wrapper for this functionality already, with methods for checking if each type of the file exists, or if any of them exist, or if only a complete file (standard or .complete) exist.

— Reply to this email directly or view it on GitHubhttps://github.com/daneren2005/Subsonic/issues/194#issuecomment-29107906.