[MediaContent] Check null or empty string for file path (#4623)
authorHaesu Gwon <haesu.gwon@samsung.com>
Wed, 5 Oct 2022 07:04:38 +0000 (16:04 +0900)
committerGitHub <noreply@github.com>
Wed, 5 Oct 2022 07:04:38 +0000 (16:04 +0900)
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInfoCommand.cs

index 1b2e53e..d42cf4f 100644 (file)
@@ -1020,6 +1020,11 @@ namespace Tizen.Content.MediaContent
             {
                 var path = InteropHelper.GetString(handle, Interop.MediaInfo.GetFilePath);
 
+                if (String.IsNullOrEmpty(path) || File.Exists(path) == false)
+                {
+                    throw new FileNotFoundException($"The media file does not exist. Path={path}.", path);
+                }
+
                 foreach (var extendedInternal in StorageManager.Storages.Where(s => s.StorageType == StorageArea.ExtendedInternal))
                 {
                     if (path.Contains(extendedInternal.RootDirectory))
@@ -1027,11 +1032,6 @@ namespace Tizen.Content.MediaContent
                         throw new UnsupportedContentException("The media is in external usb storage.");
                     }
                 }
-
-                if (File.Exists(path) == false)
-                {
-                    throw new FileNotFoundException($"The media file does not exist. Path={path}.", path);
-                }
             }
             catch (Exception ex)
             {