This commit is contained in:
mike
2025-12-12 23:53:56 +01:00
parent 87550e426a
commit 6449765890
2 changed files with 15 additions and 8 deletions

View File

@@ -49,7 +49,7 @@ class DiskReorganizer:
"""
if db_config is None:
db_config = {
'host': os.getenv('DB_HOST', 'localhost'),
'host': os.getenv('DB_HOST', '192.168.1.159'),
'port': int(os.getenv('DB_PORT', 5432)),
'database': os.getenv('DB_NAME', 'disk_reorganizer_db'),
'user': os.getenv('DB_USER', 'disk_reorg_user'),
@@ -120,7 +120,7 @@ class DiskReorganizer:
stat = file_path.stat()
size = stat.st_size
mtime = stat.st_mtime
mtime = datetime.fromtimestamp(stat.st_mtime)
# Calculate relative path for portability
rel_path = str(file_path.relative_to(disk_path))
@@ -156,6 +156,7 @@ class DiskReorganizer:
conn.commit()
except Exception as e:
conn.rollback()
logger.warning(f"\nSkipping {file_path}: {e}")
continue
@@ -182,8 +183,8 @@ class DiskReorganizer:
usage = {}
for row in cursor.fetchall():
disk = row[0]
size = row[1] or 0
count = row[2]
size = int(row[1] or 0)
count = int(row[2])
usage[disk] = {
'size': size,
'count': count,
@@ -266,7 +267,7 @@ class DiskReorganizer:
'source_path': rel_path,
'dest_disk': dest_disk,
'target_path': rel_path, # Keep same relative path
'size': size
'size': int(size)
}
plan['operations'].append(op)