[tracker] libtracker-data, tracker-store: Handle out-of-space errors by wrapping them



commit 197eab26b2def804dde7343a6e2d619bdcb3ef5d
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Feb 8 17:46:30 2011 +0100

    libtracker-data, tracker-store: Handle out-of-space errors by wrapping them
    
    Our D-Bus APIs want known errors to be passed over D-Bus, not unknown
    internal errors. So we wrap the error.

 src/libtracker-data/libtracker-data.vapi          |    3 ++-
 src/libtracker-data/tracker-db-interface-sqlite.c |    2 +-
 src/libtracker-data/tracker-db-interface.h        |    3 ++-
 src/tracker-store/tracker-resources.vala          |    8 ++++++++
 src/tracker-store/tracker-steroids.vala           |    2 ++
 5 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/src/libtracker-data/libtracker-data.vapi b/src/libtracker-data/libtracker-data.vapi
index 9f431a3..4b29ed2 100644
--- a/src/libtracker-data/libtracker-data.vapi
+++ b/src/libtracker-data/libtracker-data.vapi
@@ -32,7 +32,8 @@ namespace Tracker {
 		QUERY_ERROR,
 		CORRUPT,
 		INTERRUPTED,
-		OPEN_ERROR
+		OPEN_ERROR,
+		NO_SPACE
 	}
 
 	[CCode (cprefix = "TRACKER_DB_STATEMENT_CACHE_TYPE_", cheader_filename = "libtracker-data/tracker-db-interface.h")]
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c b/src/libtracker-data/tracker-db-interface-sqlite.c
index 8be803a..e5d4915 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -1145,7 +1145,7 @@ execute_stmt (TrackerDBInterface  *interface,
 			} else {
 				g_set_error (error,
 				             TRACKER_DB_INTERFACE_ERROR,
-				             TRACKER_DB_QUERY_ERROR,
+				             errno != ENOSPC ? TRACKER_DB_QUERY_ERROR : TRACKER_DB_NO_SPACE,
 				             "%s%s%s%s",
 				             sqlite3_errmsg (interface->db),
 				             errno != 0 ? " (" : "",
diff --git a/src/libtracker-data/tracker-db-interface.h b/src/libtracker-data/tracker-db-interface.h
index 1dcdf95..0352a4d 100644
--- a/src/libtracker-data/tracker-db-interface.h
+++ b/src/libtracker-data/tracker-db-interface.h
@@ -64,7 +64,8 @@ typedef enum {
 	TRACKER_DB_QUERY_ERROR,
 	TRACKER_DB_CORRUPT,
 	TRACKER_DB_INTERRUPTED,
-	TRACKER_DB_OPEN_ERROR
+	TRACKER_DB_OPEN_ERROR,
+	TRACKER_DB_NO_SPACE
 } TrackerDBInterfaceError;
 
 typedef enum {
diff --git a/src/tracker-store/tracker-resources.vala b/src/tracker-store/tracker-resources.vala
index d73e2aa..d556c1f 100644
--- a/src/tracker-store/tracker-resources.vala
+++ b/src/tracker-store/tracker-resources.vala
@@ -68,6 +68,8 @@ public class Tracker.Resources : Object {
 			yield Tracker.Store.queue_turtle_import (file, sender);
 
 			request.end ();
+		} catch (DBInterfaceError.NO_SPACE ie) {
+			throw new Sparql.Error.NO_SPACE (ie.message);
 		} catch (Error e) {
 			request.end (e);
 			if (e is Sparql.Error) {
@@ -128,6 +130,8 @@ public class Tracker.Resources : Object {
 			yield Tracker.Store.sparql_update (update, Tracker.Store.Priority.HIGH, sender);
 
 			request.end ();
+		} catch (DBInterfaceError.NO_SPACE ie) {
+			throw new Sparql.Error.NO_SPACE (ie.message);
 		} catch (Error e) {
 			request.end (e);
 			if (e is Sparql.Error) {
@@ -160,6 +164,8 @@ public class Tracker.Resources : Object {
 			}
 
 			return builder.end ();
+		} catch (DBInterfaceError.NO_SPACE ie) {
+			throw new Sparql.Error.NO_SPACE (ie.message);
 		} catch (Error e) {
 			request.end (e);
 			if (e is Sparql.Error) {
@@ -185,6 +191,8 @@ public class Tracker.Resources : Object {
 			yield Tracker.Store.sparql_update (update, Tracker.Store.Priority.LOW, sender);
 
 			request.end ();
+		} catch (DBInterfaceError.NO_SPACE ie) {
+			throw new Sparql.Error.NO_SPACE (ie.message);
 		} catch (Error e) {
 			request.end (e);
 			if (e is Sparql.Error) {
diff --git a/src/tracker-store/tracker-steroids.vala b/src/tracker-store/tracker-steroids.vala
index eae23e1..e0f4792 100644
--- a/src/tracker-store/tracker-steroids.vala
+++ b/src/tracker-store/tracker-steroids.vala
@@ -138,6 +138,8 @@ public class Tracker.Steroids : Object {
 
 				return builder.end ();
 			}
+		} catch (DBInterfaceError.NO_SPACE ie) {
+			throw new Sparql.Error.NO_SPACE (ie.message);
 		} catch (Error e) {
 			request.end (e);
 			if (e is Sparql.Error) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]