From: hsgwon Date: Mon, 15 Apr 2019 06:32:40 +0000 (+0900) Subject: [MediaContent] Add exception and change p/invoke function (#782) X-Git-Tag: 5.5_M2~252 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=90e0b41eccc7da4fe6551f15ae79ebde72d166ca;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [MediaContent] Add exception and change p/invoke function (#782) * [MediaController] Add exception and change p/invoke function --- diff --git a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInfoCommand.cs b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInfoCommand.cs index 3a820bf..b474646 100644 --- a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInfoCommand.cs +++ b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInfoCommand.cs @@ -476,8 +476,16 @@ namespace Tizen.Content.MediaContent /// http://tizen.org/privilege/content.write /// The media ID to delete. /// true if the matched record was found and deleted, otherwise false. - /// The or the can be used instead. - /// The is disconnected. + /// + /// The or the can be used instead.
+ /// Since API level 6, If file still exists in file system before calling this method, + /// will be thrown to keep db consistency. + ///
+ /// + /// The is disconnected.
+ /// -or-
+ /// File still exists in file system. (Since API level 6) + ///
/// The has already been disposed of. /// An error occurred while executing the command. /// is null. @@ -496,7 +504,21 @@ namespace Tizen.Content.MediaContent return false; } - CommandHelper.Delete(Interop.MediaInfo.Delete, mediaId); + Interop.MediaInfo.GetMediaFromDB(mediaId, out var handle). + ThrowIfError("Failed to delete MediaInfo."); + + var path = InteropHelper.GetString(handle, Interop.MediaInfo.GetFilePath); + + // If we don't check file existence before calling `ScanFile` method, + // The inconsistency between DB and file system could be occurred. + if (File.Exists(path)) + { + throw new InvalidOperationException("File still exists in file system. Remove it first."); + } + + // Native 'delete' function was deprecated, so we need to use 'scan file' function instead of it. + Database.ScanFile(path); + return true; }