mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-09-25 02:40:32 +00:00
Fix: convert file mtime to the configured time zone directly (#14249)
The `created` date fallback derived a naive datetime from a file's mtime using the OS-local zone, then labeled it as the configured TIME_ZONE without converting. When the OS-local zone and TIME_ZONE disagree, or when the C library can't resolve zoneinfo at all (as in some sandboxed environments, where it silently falls back to UTC), the resulting date can land on the wrong calendar day. Convert the timestamp directly into the target zone with `tz=` on fromtimestamp() instead of a naive conversion plus make_aware().
This commit is contained in:
@@ -857,8 +857,9 @@ class ConsumerPlugin(
|
||||
self.log.debug(f"Creation date from parse_date: {create_date}")
|
||||
else:
|
||||
stats = Path(self.input_doc.original_file).stat()
|
||||
create_date = timezone.make_aware(
|
||||
datetime.datetime.fromtimestamp(stats.st_mtime),
|
||||
create_date = datetime.datetime.fromtimestamp(
|
||||
stats.st_mtime,
|
||||
tz=timezone.get_current_timezone(),
|
||||
)
|
||||
self.log.debug(f"Creation date from st_mtime: {create_date}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user