mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-15 03:30:29 +03:00
update: use ctime/mtime to control _strip_and_copy_image runs
Oftentimes, the file that is copied is stripped, in which case, the file size is different. Using a file size check here means it will rerun the strip and copy every time `fdroid update` is run for any image that needs to be stripped. If the source's ctime is newer than the destination, then the process should run since it is a newly created file. Even more so with mtime, since the destination's mtime is reset based on the source's.
This commit is contained in:
parent
3cb6078059
commit
59102fb07f
2 changed files with 65 additions and 10 deletions
|
|
@ -800,14 +800,18 @@ def _strip_and_copy_image(in_file, outpath):
|
|||
It is not used at all in the F-Droid ecosystem, so its much safer
|
||||
just to remove it entirely.
|
||||
|
||||
This uses size+mtime to check for a new file since this process
|
||||
actually modifies the resulting file to strip out the EXIF.
|
||||
This only uses ctime/mtime to check for a new file since this
|
||||
process actually modifies the resulting file to strip out the EXIF.
|
||||
Therefore, whenever the file needs to be stripped, it will have a
|
||||
newer ctime and most likely a different size. The mtime is copied
|
||||
from the source to the destination, so it can be the same.
|
||||
|
||||
outpath can be path to either a file or dir. The dir that outpath
|
||||
refers to must exist before calling this.
|
||||
|
||||
Potential source of Python code to strip JPEGs without dependencies:
|
||||
http://www.fetidcascade.com/public/minimal_exif_writer.py
|
||||
|
||||
"""
|
||||
logging.debug('copying %s %s', in_file, outpath)
|
||||
|
||||
|
|
@ -823,12 +827,11 @@ def _strip_and_copy_image(in_file, outpath):
|
|||
else:
|
||||
out_file = outpath
|
||||
|
||||
if os.path.exists(out_file):
|
||||
in_stat = os.stat(in_file)
|
||||
out_stat = os.stat(out_file)
|
||||
if in_stat.st_size == out_stat.st_size \
|
||||
and in_stat.st_mtime == out_stat.st_mtime:
|
||||
return
|
||||
if os.path.exists(out_file) and (
|
||||
os.path.getmtime(in_file) <= os.path.getmtime(out_file)
|
||||
and os.path.getctime(in_file) <= os.path.getctime(out_file)
|
||||
):
|
||||
return
|
||||
|
||||
extension = common.get_extension(in_file)[1]
|
||||
if extension == 'png':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue