public static MediaContainer get_instance() {
if (MediaExportRootContainer.instance == null) {
try {
- var db = MediaDB.create("media-export");
+ var db = MediaDB.create ("media-export");
MediaExportRootContainer.instance =
new MediaExportRootContainer (db);
} catch (MediaDBError err) {
var file = File.new_for_commandline_arg (uri);
var id = Checksum.compute_for_string (ChecksumType.MD5,
file.get_uri ());
- this.media_db.delete_by_id (id);
+
+ try {
+ this.media_db.delete_by_id (id);
+ } catch (MediaDBError e) {
+ warning ("Failed to remove item %s: %s",
+ file.get_uri(),
+ e.message);
+ }
}
} catch (Error error) {
}
- var ids = media_db.get_child_ids ("0");
- var uris = get_uris ();
- foreach (var uri in uris) {
- var file = File.new_for_commandline_arg (uri);
- if (file.query_exists (null)) {
- var id = Checksum.compute_for_string (ChecksumType.MD5,
- file.get_uri ());
- ids.remove (id);
- this.harvest (file);
+ try {
+ var ids = media_db.get_child_ids ("0");
+ var uris = get_uris ();
+ foreach (var uri in uris) {
+ var file = File.new_for_commandline_arg (uri);
+ if (file.query_exists (null)) {
+ var id = Checksum.compute_for_string (ChecksumType.MD5,
+ file.get_uri ());
+ ids.remove (id);
+ this.harvest (file);
+ }
}
+ foreach (var id in ids) {
+ debug ("Id %s no longer in config, deleting...",
+ id);
+ this.media_db.delete_by_id (id);
+ }
+ this.updated ();
+ } catch (MediaDBError e) {
+ warning ("Failed to get children for root container: %s",
+ e.message);
}
- foreach (var id in ids) {
- debug ("Id %s no longer in config, deleting...",
- id);
- this.media_db.delete_by_id (id);
- }
- this.updated ();
}
private void on_file_harvested (File file) {
null);
if (rc == Sqlite.OK) {
if (statement.bind_text (1, obj.title) != Sqlite.OK ||
- statement.bind_int64 (2, (int64) obj.timestamp) != Sqlite.OK ||
+ statement.bind_int64 (2, (int64) obj.modified) != Sqlite.OK ||
statement.bind_text (3, obj.id) != Sqlite.OK) {
throw new MediaDBError.SQLITE_ERROR (db.errmsg ());
}
null);
if (rc == Sqlite.OK) {
if (statement.bind_text (1, item.id) != Sqlite.OK ||
- statement.bind_int64 (5, (int64) item.timestamp) != Sqlite.OK ||
+ statement.bind_int64 (5, (int64) item.modified) != Sqlite.OK ||
statement.bind_text (2, item.title) != Sqlite.OK) {
throw new MediaDBError.SQLITE_ERROR (db.errmsg ());
}
try {
if (obj != null) {
- obj.timestamp = statement.column_int64 (18);
+ obj.modified = statement.column_int64 (18);
add_uris (obj);
}
} catch (MediaDBError err) {