[gnome-games] local-cover: Fetch only the required attributes
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] local-cover: Fetch only the required attributes
- Date: Thu, 14 Jun 2018 09:07:17 +0000 (UTC)
commit 03488ab1d0f5a4f698e33722bb117b0435db83a7
Author: theawless <theawless gmail com>
Date: Sun Jun 10 14:09:14 2018 +0530
local-cover: Fetch only the required attributes
Fetching fewer attributes speeds up loading time. Also, users are likely
to have covers with sane image extensions, hence use fast content type.
https://gitlab.gnome.org/GNOME/gnome-games/issues/11
src/utils/local-cover.vala | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/src/utils/local-cover.vala b/src/utils/local-cover.vala
index 4172758..4a26d33 100644
--- a/src/utils/local-cover.vala
+++ b/src/utils/local-cover.vala
@@ -58,7 +58,8 @@ public class Games.LocalCover : Object, Cover {
string cover_path = null;
var directory = new Directory (parent);
- directory.foreach ("*", (sibbling) => {
+ var attributes = string.join (",", FileAttribute.STANDARD_NAME,
FileAttribute.STANDARD_FAST_CONTENT_TYPE);
+ directory.foreach (attributes, (sibbling) => {
var sibbling_basename = sibbling.get_name ();
if (sibbling_basename == basename)
return false;
@@ -66,7 +67,7 @@ public class Games.LocalCover : Object, Cover {
if (!sibbling_basename.has_prefix (prefix))
return false;
- var type = sibbling.get_content_type ();
+ var type = sibbling.get_attribute_string (FileAttribute.STANDARD_FAST_CONTENT_TYPE);
if (!type.has_prefix ("image"))
return false;
@@ -87,13 +88,14 @@ public class Games.LocalCover : Object, Cover {
string cover_path = null;
var directory = new Directory (parent);
- directory.foreach ("*", (sibbling) => {
+ var attributes = string.join (",", FileAttribute.STANDARD_NAME,
FileAttribute.STANDARD_FAST_CONTENT_TYPE);
+ directory.foreach (attributes, (sibbling) => {
var sibbling_basename = sibbling.get_name ();
if (!sibbling_basename.has_prefix ("cover.") &&
!sibbling_basename.has_prefix ("folder."))
return false;
- var type = sibbling.get_content_type ();
+ var type = sibbling.get_attribute_string (FileAttribute.STANDARD_FAST_CONTENT_TYPE);
if (!type.has_prefix ("image"))
return false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]