Jason Tackaberry wrote: > Hrmm, first of all, unrelated, mtime += stat_res[stat.ST_MTIME] looks a > bit like a kludge? Are you just later testing that the mtime returned > here is greater than the last known mtime? In this case, if you delete > one of these "overlay" files (or whatever you're calling them) then the > mtime returned here will be less than before, even though the file will > need to be rescanned in that case. I guess that means just testing > mtime != last_mtime, rather than mtime > last_mtime. Maybe you're > already doing that, but just thought I'd point it out.
Yes, I check on not equal. > Now, how do we fix this function. Well, we could do it a couple ways. > First of all, the logic looks questionable to me. You said this means > if I have foo.avi in some directory, and then add foo.jpg that foo.avi > will get rescanned. I don't know that I like this idea. It seems > kinda hackish. Yes, it is. > What makes sense to me rather is to have a list of special > extensions (like .srt, etc.) and a list of special files (like > cover.jpg) that beacon could ask kaa.metadata for, and instead do > specific lookups on these files. We could do that, sure. This means we need to make sure we don't miss something. > Also, if you ask me, foo.avi.srt makes more sense than foo.srt. But > maybe people don't do this in practice, I dunno. I have no idea. But there are some requests from people how use the language inside the filename for srt files, like foo-english.avi.srt or stuff like that. Well, we could just not support that in beacon and we are done (right now kaa.metadata also does not support this). About foo.srt against foo.avi.srt, I guess people use both, so we should support both. > But the main benefit here is with a list of extensions that we know are > special, beacon can do O(1) lookups: > > ext = os.path.splitext(self._beacon_data['name'])[1] > special_exts = kaa.metadata.get_special_exts_for_type(ext) > listdir_file_map = self._beacon_parent._beacon_listdir(cache=True)[1] > for ext in special_exts: > if basename+ext in listdir_file_map: > mtime += listdir_file_map[basename+ext][3][stat.ST_MTIME] > > Maybe you want to avoid splitext() or whatever, but you get the idea. > This is just rough code. But the above logic reduces the complexity to > O(n) and when n=2500, that's a difference of 6.25 million iterations. Sounds like a good speedup. I will keep that in mind. For now, beacon works like it is now and speedups are not very high an my todo list. I first need to finish rom drive support. Dischi -- "Alcohol doesn't solve any problem...but fuck it neither does milk" --- A wise man?
pgpdIH4oXGr5g.pgp
Description: PGP signature