🐛 Fix file migration
This commit is contained in:
@@ -19,6 +19,8 @@ public class FileMigrationService(AppDatabase db, ILogger<FileMigrationService>
|
|||||||
logger.LogDebug("Found {Count} cloud files to migrate.", cloudFiles.Count);
|
logger.LogDebug("Found {Count} cloud files to migrate.", cloudFiles.Count);
|
||||||
|
|
||||||
foreach (var cf in cloudFiles)
|
foreach (var cf in cloudFiles)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var ext = Path.GetExtension(cf.Name);
|
var ext = Path.GetExtension(cf.Name);
|
||||||
var mimeType = ext != "" && MimeTypes.TryGetMimeType(ext, out var mime) ? mime : "application/octet-stream";
|
var mimeType = ext != "" && MimeTypes.TryGetMimeType(ext, out var mime) ? mime : "application/octet-stream";
|
||||||
@@ -76,9 +78,20 @@ public class FileMigrationService(AppDatabase db, ILogger<FileMigrationService>
|
|||||||
|
|
||||||
cf.ObjectId = fileObject.Id;
|
cf.ObjectId = fileObject.Id;
|
||||||
cf.Object = fileObject;
|
cf.Object = fileObject;
|
||||||
}
|
|
||||||
|
|
||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
|
logger.LogInformation("Migrated file {FileId} successfully.", cf.Id);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.LogError(ex,
|
||||||
|
"Failed migrating file {FileId}. ObjectId={ObjectId}, PoolId={PoolId}, StorageId={StorageId}",
|
||||||
|
cf.Id,
|
||||||
|
cf.ObjectId,
|
||||||
|
cf.PoolId,
|
||||||
|
cf.StorageId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logger.LogInformation("Cloud file migration completed.");
|
logger.LogInformation("Cloud file migration completed.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user