summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2020-06-11 00:13:54 +0200
committerJens Georg <mail@jensge.org>2020-06-15 20:06:04 +0200
commit6bd61a5dbe3269b7f0b5c6474b90617c41a931bf (patch)
tree5a88e3fd8749ea6f1deabbdb1a7f2aedc58583db
parent1c31f4fde3ac4065b65f7c312b36e89844fbd69e (diff)
downloadrygel-6bd61a5dbe3269b7f0b5c6474b90617c41a931bf.tar.gz
media-export: Get rid of "blacklist"
-rwxr-xr-xexamples/mx-info44
-rw-r--r--src/plugins/media-export/rygel-media-export-harvester.vala8
-rw-r--r--src/plugins/media-export/rygel-media-export-harvesting-task.vala2
-rw-r--r--src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala20
-rw-r--r--src/plugins/media-export/rygel-media-export-media-cache.vala8
-rw-r--r--src/plugins/media-export/rygel-media-export-sql-factory.vala47
6 files changed, 69 insertions, 60 deletions
diff --git a/examples/mx-info b/examples/mx-info
index 99fe664b..42f5253b 100755
--- a/examples/mx-info
+++ b/examples/mx-info
@@ -61,13 +61,13 @@ Technical information:
Channels: %(channels)d
Color depths: %(depth)d
"""
-BLACKLIST_QUERY = """
-SELECT b.timestamp FROM blacklist b WHERE b.uri = :uri
+IGNORELIST_QUERY = """
+SELECT b.timestamp FROM ignorelist b WHERE b.uri = :uri
"""
-BLACKLIST_TEMPLATE = 'File %(uri)s was blacklisted on %(date)s'
-SHOW_BLACKLIST_QUERY = 'SELECT timestamp, uri FROM blacklist'
-UNBLACKLIST_QUERY = 'DELETE FROM blacklist where uri = :uri'
+IGNORELIST_TEMPLATE = 'File %(uri)s was ignore on %(date)s'
+SHOW_IGNORELIST_QUERY = 'SELECT timestamp, uri FROM ignorelist'
+UNIGNORELIST_QUERY = 'DELETE FROM ignorelist where uri = :uri'
def ensure_uri(string):
if not string.startswith ('file://'):
@@ -77,12 +77,12 @@ def ensure_uri(string):
parser = argparse.ArgumentParser (description = "MediaExport database tool")
parser.add_argument ('uris', metavar='URI', nargs = '+', type = ensure_uri,
help = 'URIs to dump infos for')
-parser.add_argument ('-u, --unblacklist', action = 'store_true',
- dest = 'unblacklist',
- help = 'Remove uris from database\'s blacklist')
-parser.add_argument ('--show-blacklist', action = 'store_true',
- dest = 'show_blacklist',
- help = 'Show contents of the blacklist')
+parser.add_argument ('-u, --unignore', action = 'store_true',
+ dest = 'unignore',
+ help = 'Remove uris from database\'s ignorelist')
+parser.add_argument ('--show-ignorelist', action = 'store_true',
+ dest = 'show_ignorelist',
+ help = 'Show contents of the ignorelist')
args = parser.parse_args ()
rygel_db = os.path.join (BaseDirectory.xdg_cache_home, "rygel", "media-export.db")
@@ -95,23 +95,23 @@ if int(info[0]) < 16:
print("Unsupported schema version or not a Rygel cache")
sys.exit (1)
-has_blacklist = int(info[0]) >= 17
+has_ignorelist = int(info[0]) >= 18
-if not has_blacklist and (args.unblacklist or args.show_blacklist):
- print ('Database version is too old for blacklists, cannot unblacklist')
+if not has_ignorelist and (args.unignorelist or args.show_ignorelist):
+ print ('Database version is too old for ignorelists, cannot unignorelist')
sys.exit (1)
-if has_blacklist and args.show_blacklist:
- c.execute (SHOW_BLACKLIST_QUERY)
+if has_ignorelist and args.show_ignorelist:
+ c.execute (SHOW_IGNORELIST_QUERY)
for row in c:
t = time.gmtime(row[0])
- print (BLACKLIST_TEMPLATE % { "uri" : row[1],
+ print (IGNORELIST_TEMPLATE % { "uri" : row[1],
"date" : time.strftime("%a, %d %b %Y %H:%M:%S +0000", t)})
sys.exit(0)
-if has_blacklist and args.unblacklist:
+if has_ignorelist and args.unignorelist:
for uri in args.uris:
- c.execute (UNBLACKLIST_QUERY, { 'uri' : uri })
+ c.execute (UNIGNORELIST_QUERY, { 'uri' : uri })
conn.commit()
else:
for uri in args.uris:
@@ -140,9 +140,9 @@ else:
"disc" : row[21],
"title": row[22]})
- if has_blacklist:
- c.execute (BLACKLIST_QUERY, {"uri": uri})
+ if has_ignorelist:
+ c.execute (IGNORELIST_QUERY, {"uri": uri})
for row in c:
t = time.gmtime(row[0])
- print (BLACKLIST_TEMPLATE % { "uri" : uri,
+ print (IGNORELIST_TEMPLATE % { "uri" : uri,
"date" : time.strftime("%a, %d %b %Y %H:%M:%S +0000", t)})
diff --git a/src/plugins/media-export/rygel-media-export-harvester.vala b/src/plugins/media-export/rygel-media-export-harvester.vala
index 0d470320..3c4f3fd3 100644
--- a/src/plugins/media-export/rygel-media-export-harvester.vala
+++ b/src/plugins/media-export/rygel-media-export-harvester.vala
@@ -77,14 +77,14 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
info.get_content_type () == "text/plain" ||
info.get_content_type () == "application/x-cd-image";
var cache = MediaCache.get_default ();
- var is_blacklisted = cache.is_blacklisted (file);
+ var is_ignored = cache.is_ignored (file);
- if (is_blacklisted) {
- debug ("URI %s is not eligible due to blacklisting",
+ if (is_ignored) {
+ debug ("URI %s is not eligible due, it is ignored",
file.get_uri ());
}
- return is_supported_content_type && ! is_blacklisted;
+ return is_supported_content_type && ! is_ignored;
}
/**
diff --git a/src/plugins/media-export/rygel-media-export-harvesting-task.vala b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
index c22c9733..1cc4b8a5 100644
--- a/src/plugins/media-export/rygel-media-export-harvesting-task.vala
+++ b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
@@ -359,7 +359,7 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
file.get_uri (),
error.message);
- this.cache.blacklist (file);
+ this.cache.ignore (file);
this.files.poll ();
this.do_update ();
diff --git a/src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala b/src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala
index c628dd6c..b516558b 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala
@@ -90,7 +90,12 @@ internal class Rygel.MediaExport.MediaCacheUpgrader {
switch (old_version) {
case 16:
- this.update_v16_v17 ();
+ this.update_v17_v18 (false);
+ // We jump 17 here since 17 -> 18 is just a table rename
+ old_version++;
+ break;
+ case 17:
+ this.update_v17_v18 (true);
break;
default:
warning (_("Cannot upgrade from version %d"), old_version);
@@ -101,18 +106,21 @@ internal class Rygel.MediaExport.MediaCacheUpgrader {
}
}
- private void update_v16_v17 () {
+ private void update_v17_v18 (bool move_data) {
try {
this.database.begin ();
- this.database.exec (this.sql.make (SQLString.CREATE_BLACKLIST_TABLE));
- this.database.exec (this.sql.make (SQLString.CREATE_BLACKLIST_INDEX));
- database.exec ("UPDATE schema_info SET version = '17'");
+ this.database.exec (this.sql.make (SQLString.CREATE_IGNORELIST_TABLE));
+ this.database.exec (this.sql.make (SQLString.CREATE_IGNORELIST_INDEX));
+ if (move_data) {
+ database.exec ("INSERT INTO ignorelist SELECT * FROM blacklist");
+ }
+ database.exec ("UPDATE schema_info SET VERSION = '18'");
this.database.commit ();
this.database.exec ("VACUUM");
this.database.analyze ();
} catch (Database.DatabaseError error) {
database.rollback ();
- warning (_("Database upgrade failed: %s"), error.message);
+ warning (_("Database upgrade to v18 failed: %s"), error.message);
database = null;
}
}
diff --git a/src/plugins/media-export/rygel-media-export-media-cache.vala b/src/plugins/media-export/rygel-media-export-media-cache.vala
index b9a17bef..a494b255 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -587,11 +587,11 @@ public class Rygel.MediaExport.MediaCache : Object {
return object.id;
}
- public void blacklist (File file) {
+ public void ignore (File file) {
try {
GLib.Value[] values = { file.get_uri (),
new GLib.DateTime.now_utc ().to_unix () };
- this.db.exec (this.sql.make (SQLString.ADD_TO_BLACKLIST),
+ this.db.exec (this.sql.make (SQLString.ADD_TO_IGNORELIST),
values);
} catch (DatabaseError error) {
warning (_("Failed to add %s to ignored files: %s"),
@@ -600,11 +600,11 @@ public class Rygel.MediaExport.MediaCache : Object {
}
}
- public bool is_blacklisted (File file) {
+ public bool is_ignored (File file) {
try {
GLib.Value[] values = { file.get_uri () };
- return this.query_value (SQLString.CHECK_BLACKLIST,
+ return this.query_value (SQLString.CHECK_IGNORELIST,
values) == 1;
} catch (DatabaseError error) {
warning (_("Failed to get whether URI %s is ignored: %s"),
diff --git a/src/plugins/media-export/rygel-media-export-sql-factory.vala b/src/plugins/media-export/rygel-media-export-sql-factory.vala
index 8d4ee4ed..c7e24371 100644
--- a/src/plugins/media-export/rygel-media-export-sql-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-sql-factory.vala
@@ -80,10 +80,10 @@ internal enum Rygel.MediaExport.SQLString {
IS_GUARDED,
UPDATE_GUARDED_OBJECT,
TRIGGER_REFERENCE,
- CREATE_BLACKLIST_TABLE,
- CREATE_BLACKLIST_INDEX,
- ADD_TO_BLACKLIST,
- CHECK_BLACKLIST
+ CREATE_IGNORELIST_TABLE,
+ CREATE_IGNORELIST_INDEX,
+ ADD_TO_IGNORELIST,
+ CHECK_IGNORELIST
}
internal class Rygel.MediaExport.SQLFactory : Object {
@@ -173,12 +173,13 @@ internal class Rygel.MediaExport.SQLFactory : Object {
"LEFT OUTER JOIN meta_data m " +
"ON o.upnp_id = m.object_fk %s";
- private const string CHECK_BLACKLIST_STRING =
- "SELECT COUNT(1) FROM blacklist b " +
+ private const string CHECK_IGNORELIST_STRING =
+ "SELECT COUNT(1) FROM ignorelist b " +
"WHERE b.uri = ?";
- private const string ADD_TO_BLACKLIST_STRING =
- "INSERT OR REPLACE INTO blacklist (uri, timestamp) VALUES (?,?)";
+ private const string ADD_TO_IGNORELIST_STRING =
+ "INSERT OR REPLACE INTO ignorelist (uri, timestamp) VALUES (?,?)";
+
private const string GET_OBJECT_COUNT_BY_FILTER_STRING =
"SELECT COUNT(1) FROM meta_data m %s";
@@ -199,7 +200,7 @@ internal class Rygel.MediaExport.SQLFactory : Object {
"WHERE _column IS NOT NULL %s %s" +
"LIMIT ?,?";
- internal const string SCHEMA_VERSION = "17";
+ internal const string SCHEMA_VERSION = "18";
internal const string CREATE_META_DATA_TABLE_STRING =
"CREATE TABLE meta_data (size INTEGER NOT NULL, " +
"mime_type TEXT NOT NULL, " +
@@ -224,8 +225,8 @@ internal class Rygel.MediaExport.SQLFactory : Object {
"object_fk_id REFERENCES Object(upnp_id) " +
"ON DELETE CASCADE);";
- private const string CREATE_BLACKLIST_TABLE_STRING =
- "CREATE TABLE blacklist (uri TEXT, timestamp INTEGER NOT NULL);";
+ private const string CREATE_IGNORELIST_TABLE_STRING =
+ "CREATE TABLE ignorelist (uri TEXT, timestamp INTEGER NOT NULL);";
private const string SCHEMA_STRING =
"CREATE TABLE schema_info (version TEXT NOT NULL, " +
@@ -243,7 +244,7 @@ internal class Rygel.MediaExport.SQLFactory : Object {
"container_update_id INTEGER, " +
"is_guarded INTEGER, " +
"reference_id TEXT DEFAULT NULL);" +
- CREATE_BLACKLIST_TABLE_STRING +
+ CREATE_IGNORELIST_TABLE_STRING +
"INSERT INTO schema_info (version) VALUES ('" +
SQLFactory.SCHEMA_VERSION + "'); ";
@@ -299,10 +300,10 @@ internal class Rygel.MediaExport.SQLFactory : Object {
"CREATE INDEX IF NOT EXISTS idx_meta_data_album on meta_data(album);" +
"CREATE INDEX IF NOT EXISTS idx_meta_data_artist_album on " +
"meta_data(author, album);" +
- CREATE_BLACKLIST_INDEX_STRING;
+ CREATE_IGNORELIST_INDEX_STRING;
- private const string CREATE_BLACKLIST_INDEX_STRING =
- "CREATE INDEX IF NOT EXISTS idx_blacklist on blacklist(uri);";
+ private const string CREATE_IGNORELIST_INDEX_STRING =
+ "CREATE INDEX IF NOT EXISTS idx_ignorelist on ignorelist(uri);";
private const string EXISTS_CACHE_STRING =
"SELECT m.size, o.timestamp, m.mime_type, o.uri FROM Object o " +
@@ -379,14 +380,14 @@ internal class Rygel.MediaExport.SQLFactory : Object {
return UPDATE_GUARDED_OBJECT_STRING;
case SQLString.TRIGGER_REFERENCE:
return DELETE_REFERENCE_TRIGGER_STRING;
- case SQLString.CREATE_BLACKLIST_TABLE:
- return CREATE_BLACKLIST_TABLE_STRING;
- case SQLString.CREATE_BLACKLIST_INDEX:
- return CREATE_BLACKLIST_INDEX_STRING;
- case SQLString.ADD_TO_BLACKLIST:
- return ADD_TO_BLACKLIST_STRING;
- case SQLString.CHECK_BLACKLIST:
- return CHECK_BLACKLIST_STRING;
+ case SQLString.CREATE_IGNORELIST_TABLE:
+ return CREATE_IGNORELIST_TABLE_STRING;
+ case SQLString.CREATE_IGNORELIST_INDEX:
+ return CREATE_IGNORELIST_INDEX_STRING;
+ case SQLString.ADD_TO_IGNORELIST:
+ return ADD_TO_IGNORELIST_STRING;
+ case SQLString.CHECK_IGNORELIST:
+ return CHECK_IGNORELIST_STRING;
default:
assert_not_reached ();
}