Quellcode durchsuchen

refactor(media): 移除冗余的 dbFilePath 字段赋值

chendeben vor 9 Monaten
Ursprung
Commit
9cade711fc

+ 1 - 2
entry/src/main/ets/common/util/MediaTable.ets

@@ -132,8 +132,7 @@ export default  class MediaTable {
           item.remote_rel_path = relativePath;
           // 更新filePath为相对路径
           item.filePath = relativePath;
-        item.dbFilePath = relativePath;
-          Logger.info(RdbUtils.RDB_TAG, `WebDAV URL转换: 原始URL -> 存储路径: ${relativePath}`);
+        Logger.info(RdbUtils.RDB_TAG, `WebDAV URL转换: 原始URL -> 存储路径: ${relativePath}`);
         }
       }
 

+ 0 - 6
entry/src/main/ets/common/util/RemoteDriveManager.ets

@@ -959,14 +959,12 @@ export class RemoteDriveManager {
       const relative = item.remote_rel_path || WebDavUrlUtil.toStoragePath(item.filePath);
       if (relative) {
         item.remote_rel_path = relative;
-        item.dbFilePath = relative;
         return relative;
       }
       return null;
     }
     if (item.type === CommonConstants.TYPE_SMB || item.type === CommonConstants.TYPE_NAVIDROME) {
       if (item.remote_rel_path) {
-        item.dbFilePath = item.remote_rel_path;
         return item.remote_rel_path;
       }
       return null;
@@ -995,7 +993,6 @@ export class RemoteDriveManager {
     target.year = cached.year || target.year;
     target.webdav_account_id = target.webdav_account_id || cached.webdav_account_id;
     target.remote_rel_path = target.remote_rel_path || cached.remote_rel_path || storagePath;
-    target.dbFilePath = storagePath;
   }
 
   // 将FileInfo转换为VideoItem
@@ -1048,7 +1045,6 @@ export class RemoteDriveManager {
       const relMatch = absoluteUrl.match(/^https?:\/\/[^\/]+(?::\d+)?(\/.*)$/i);
       if (relMatch && relMatch[1]) {
         videoItem.remote_rel_path = relMatch[1];
-        videoItem.dbFilePath = relMatch[1];
       }
     } catch (e) {
       Logger.warn(TAG, '计算相对路径失败: ' + (e as Error).message);
@@ -1081,7 +1077,6 @@ export class RemoteDriveManager {
       videoItem.webdav_account_id = account.id.toString();
     }
     videoItem.remote_rel_path = sanitizedRelative;
-    videoItem.dbFilePath = sanitizedRelative;
     const hostForDisplay = account.host && account.host.trim().length > 0
       ? account.host.trim()
       : (account.id?.toString() ?? '');
@@ -1172,7 +1167,6 @@ export class RemoteDriveManager {
     videoItem.size = Utility.formatFSize(song.size ?? 0);
     videoItem.webdav_account_id = account.id?.toString();
     videoItem.remote_rel_path = song.id;
-    videoItem.dbFilePath = song.id;
     videoItem.bit_rate = song.bitRate ? song.bitRate.toString() : undefined;
     videoItem.mimeType = song.contentType;
     return videoItem;

+ 0 - 7
entry/src/main/ets/view/LocalMusic.ets

@@ -374,7 +374,6 @@ function cloneVideoItem(item: VideoItem): VideoItem {
   copy.disc = item.disc;
   copy.webdav_account_id = item.webdav_account_id;
   copy.remote_rel_path = item.remote_rel_path;
-  copy.dbFilePath = item.dbFilePath;
   return copy;
 }
 
@@ -1563,9 +1562,6 @@ export struct LocalMusic {
     if (source.remote_rel_path && StrUtil.isEmpty(target.remote_rel_path)) {
       target.remote_rel_path = source.remote_rel_path;
     }
-    if (source.dbFilePath) {
-      target.dbFilePath = source.dbFilePath;
-    }
   }
 
   private async hydrateRemoteSongFromDb(item: VideoItem | undefined): Promise<void> {
@@ -1585,7 +1581,6 @@ export struct LocalMusic {
       if (StrUtil.isEmpty(item.remote_rel_path)) {
         item.remote_rel_path = storagePath;
       }
-      item.dbFilePath = storagePath;
       if (item === this.currentSong) {
         if (StrUtil.isNotEmpty(item.name)) {
           this.name = item.name;
@@ -1637,7 +1632,6 @@ export struct LocalMusic {
       return;
     }
     target.remote_rel_path = target.remote_rel_path || storagePath;
-    target.dbFilePath = storagePath;
     const table = new MediaTable(this.context);
     await new Promise<void>((resolve) => {
       table.getRdbStore(this.context as Context, () => resolve());
@@ -1645,7 +1639,6 @@ export struct LocalMusic {
     const cloneItem = cloneVideoItem(target);
     cloneItem.filePath = storagePath;
     cloneItem.remote_rel_path = storagePath;
-    cloneItem.dbFilePath = storagePath;
     cloneItem.parentPath = this.extractParentPathFromStoragePath(storagePath);
     await table.saveOrUpdateWebDavItem(cloneItem);
   }