[banshee] Importing: bail for nonreadable files (bgo#725185)
- From: Andrés Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] Importing: bail for nonreadable files (bgo#725185)
- Date: Tue, 11 Mar 2014 20:23:09 +0000 (UTC)
commit 347f3def93ad11340cac1b46959dd4204fa23568
Author: Dmitriy Petukhov <dimart sp gmail com>
Date: Tue Mar 11 21:13:40 2014 +0100
Importing: bail for nonreadable files (bgo#725185)
There's no point in importing files that can be
found but which cannot be read, because their
playback will fail anyway. Rather fail fast
telling the user what went wrong during the
import.
Signed-off-by: Andrés G. Aragoneses <knocte gmail com>
src/Core/Banshee.Core/Banshee.Core.csproj | 1 +
src/Core/Banshee.Core/Banshee.IO/File.cs | 5 +++
src/Core/Banshee.Core/Banshee.IO/IDemuxVfs.cs | 4 +--
.../Banshee.IO/IFileSystemEntryPermissions.cs | 33 ++++++++++++++++++++
src/Core/Banshee.Core/Makefile.am | 1 +
.../DatabaseImportManager.cs | 6 +++
6 files changed, 47 insertions(+), 3 deletions(-)
---
diff --git a/src/Core/Banshee.Core/Banshee.Core.csproj b/src/Core/Banshee.Core/Banshee.Core.csproj
index 112545c..fd57297 100644
--- a/src/Core/Banshee.Core/Banshee.Core.csproj
+++ b/src/Core/Banshee.Core/Banshee.Core.csproj
@@ -141,6 +141,7 @@
<Compile Include="Banshee.IO\Tests.cs" />
<Compile Include="Banshee.Collection\YearInfo.cs" />
<Compile Include="Banshee.IO\ProviderConfiguration.cs" />
+ <Compile Include="Banshee.IO\IFileSystemEntryPermissions.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\contributors.xml">
diff --git a/src/Core/Banshee.Core/Banshee.IO/File.cs b/src/Core/Banshee.Core/Banshee.IO/File.cs
index 933e0dd..9aa36d5 100644
--- a/src/Core/Banshee.Core/Banshee.IO/File.cs
+++ b/src/Core/Banshee.Core/Banshee.IO/File.cs
@@ -73,5 +73,10 @@ namespace Banshee.IO
{
return Provider.File.OpenWrite (uri, overwrite);
}
+
+ public static IFileSystemEntryPermissions GetPermissions (SafeUri uri)
+ {
+ return Provider.CreateDemuxVfs (uri);
+ }
}
}
diff --git a/src/Core/Banshee.Core/Banshee.IO/IDemuxVfs.cs b/src/Core/Banshee.Core/Banshee.IO/IDemuxVfs.cs
index f2532ae..5acab4a 100644
--- a/src/Core/Banshee.Core/Banshee.IO/IDemuxVfs.cs
+++ b/src/Core/Banshee.Core/Banshee.IO/IDemuxVfs.cs
@@ -28,9 +28,7 @@
namespace Banshee.IO
{
- public interface IDemuxVfs : TagLib.File.IFileAbstraction
+ public interface IDemuxVfs : IFileSystemEntryPermissions, TagLib.File.IFileAbstraction
{
- bool IsReadable { get; }
- bool IsWritable { get; }
}
}
diff --git a/src/Core/Banshee.Core/Banshee.IO/IFileSystemEntryPermissions.cs
b/src/Core/Banshee.Core/Banshee.IO/IFileSystemEntryPermissions.cs
new file mode 100644
index 0000000..e6d6349
--- /dev/null
+++ b/src/Core/Banshee.Core/Banshee.IO/IFileSystemEntryPermissions.cs
@@ -0,0 +1,33 @@
+//
+// Author:
+// Dmitriy Petukhov <dimart sp gmail com>
+//
+// Copyright (C) 2014 Dmitriy Petukhov
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+namespace Banshee.IO
+{
+ public interface IFileSystemEntryPermissions
+ {
+ bool IsReadable { get; }
+ bool IsWritable { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/Core/Banshee.Core/Makefile.am b/src/Core/Banshee.Core/Makefile.am
index 3b0e064..1e2929c 100644
--- a/src/Core/Banshee.Core/Makefile.am
+++ b/src/Core/Banshee.Core/Makefile.am
@@ -45,6 +45,7 @@ SOURCES = \
Banshee.IO/IDemuxVfs.cs \
Banshee.IO/IDirectory.cs \
Banshee.IO/IFile.cs \
+ Banshee.IO/IFileSystemEntryPermissions.cs \
Banshee.IO/IProvider.cs \
Banshee.IO/Provider.cs \
Banshee.IO/ProviderConfiguration.cs \
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseImportManager.cs
b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseImportManager.cs
index 6ae854d..6abe6aa 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseImportManager.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseImportManager.cs
@@ -165,6 +165,12 @@ namespace Banshee.Collection.Database
return null;
}
+ if (!Banshee.IO.File.GetPermissions (uri).IsReadable) {
+ throw new InvalidFileException (String.Format (
+ Catalog.GetString ("File is not readable so it could not be imported: {0}"),
+ Path.GetFileName (uri.LocalPath)));
+ }
+
if (Banshee.IO.File.GetSize (uri) == 0) {
throw new InvalidFileException (String.Format (
Catalog.GetString ("File is empty so it could not be imported: {0}"),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]