Skip to content

Update encryptor.py: remove deprecation warning unaware datetimes #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/fast_file_encryption/encryptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import io
import json
import os
from datetime import datetime
from datetime import datetime, timezone
from pathlib import Path
from typing import Dict, Any, Optional, Tuple, Union, BinaryIO

Expand Down Expand Up @@ -357,9 +357,9 @@ def _add_source_metadata(source: Path, meta: Dict[str, Any]) -> Dict[str, Any]:
if 'file_size' not in meta:
meta['file_size'] = source.stat().st_size
if 'created' not in meta:
meta['created'] = datetime.utcfromtimestamp(source.stat().st_ctime).isoformat()
meta['created'] = datetime.fromtimestamp(source.stat().st_ctime, timezone.utc).isoformat()
if 'modified' not in meta:
meta['modified'] = datetime.utcfromtimestamp(source.stat().st_mtime).isoformat()
meta['modified'] = datetime.fromtimestamp(source.stat().st_mtime, timezone.utc).isoformat()
return meta

def save_encrypted(self, source_data: bytes, destination: Path, meta: Dict[str, Any] = None):
Expand Down