Merge lp:~benwaffle/noise/changes into lp:~elementary-apps/noise/trunk

Proposed by Ben
Status: Work in progress
Proposed branch: lp:~benwaffle/noise/changes
Merge into: lp:~elementary-apps/noise/trunk
Diff against target: 153 lines (+41/-8)
5 files modified
src/FileOperator.vala (+1/-1)
src/LocalBackend/LocalLibrary.vala (+20/-5)
src/LocalBackend/LocalMedia.vala (+18/-1)
src/Views/Wrappers/ViewWrapper.vala (+1/-0)
src/Widgets/InfoPanel.vala (+1/-1)
To merge this branch: bzr merge lp:~benwaffle/noise/changes
Reviewer Review Type Date Requested Status
Cody Garver (community) Needs Fixing
Corentin Noël code Approve
Review via email: mp+294697@code.launchpad.net

Commit message

Detect library changes on startup and while running.

To post a comment you must log in.
Revision history for this message
Corentin Noël (tintou) wrote :

The code seems good, I need to find some track to test it

review: Approve (code)
Revision history for this message
Cody Garver (codygarver) wrote :

Adds a long startup time for my 1500 track, 13 GB library, author is investigating

review: Needs Fixing
Revision history for this message
Zisu Andrei (matzipan) wrote :

I might be wrong here, but if I were to guess, the blocking is because the rescan_music_folder_async method does not have any yield statements?

Unmerged revisions

1924. By Ben

Update media list when file ops are done

1923. By Ben

resync library on startup

1922. By Ben

Update database when media is changed

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/FileOperator.vala'
2--- src/FileOperator.vala 2016-02-07 16:33:45 +0000
3+++ src/FileOperator.vala 2016-05-14 04:57:26 +0000
4@@ -93,7 +93,7 @@
5 var file = music_folder.get_child (file_info.get_name ());
6
7 if(file_info.get_file_type() == FileType.DIRECTORY) {
8- dirs.add (file.get_uri ());
9+ dirs.add (file.get_path ());
10 list_recursive_directory (file, ref dirs);
11 }
12 }
13
14=== modified file 'src/LocalBackend/LocalLibrary.vala'
15--- src/LocalBackend/LocalLibrary.vala 2016-04-29 15:37:31 +0000
16+++ src/LocalBackend/LocalLibrary.vala 2016-05-14 04:57:26 +0000
17@@ -78,10 +78,16 @@
18 init_database ();
19 fo.connect_to_manager ();
20
21+ var to_remove = new Gee.TreeSet<Media> ();
22+
23 // Load all media from database
24 var media_ids = get_rowids_from_table (Database.Media.TABLE_NAME);
25 foreach (var media_id in media_ids) {
26 var m = new LocalMedia (media_id, connection);
27+ if (!m.file.query_exists ()) { // ignore files that don't exist
28+ to_remove.add (m);
29+ continue;
30+ }
31 _medias.set (m.rowid, m);
32 // Append the media into an album.
33 if (m.get_album_hashkey () in album_info.keys) {
34@@ -96,6 +102,10 @@
35 }
36 }
37
38+ if (!to_remove.is_empty) {
39+ remove_medias (to_remove, false);
40+ }
41+
42 // Load all smart playlists from database
43 var sp_ids = get_rowids_from_table (Database.SmartPlaylists.TABLE_NAME);
44 if (sp_ids.is_empty) {
45@@ -114,6 +124,8 @@
46 var p = new LocalStaticPlaylist (p_id, connection);
47 _playlists.add (p);
48 }
49+
50+ rescan_music_folder ();
51 }
52
53 /*
54@@ -252,7 +264,6 @@
55
56 public void rescan_music_folder () {
57 if (start_file_operations (_("Rescanning music for changes. This may take a while…"))) {
58- App.main_window.update_sensitivities.begin ();
59 rescan_music_folder_async.begin ();
60 }
61 }
62@@ -268,13 +279,16 @@
63
64 foreach (var m in get_medias ()) {
65 if (!m.isTemporary && !m.isPreview && m.uri.contains (music_folder_dir))
66-
67- if (!File.new_for_uri (m.uri).query_exists ())
68- to_remove.add (m);
69+ if (!m.file.query_exists ())
70+ to_remove.add (m);
71 if (files.contains (m.uri))
72 files.remove (m.uri);
73 }
74
75+ foreach (var f in files) {
76+ to_import.add (f);
77+ }
78+
79 if (!to_import.is_empty) {
80 debug ("Importing %d new songs", to_import.size);
81 fo.resetProgress (to_import.size - 1);
82@@ -848,7 +862,8 @@
83
84 NotificationManager.get_default ().update_progress (message, 0.0);
85 _doing_file_operations = true;
86- App.main_window.update_sensitivities.begin ();
87+ if (App.main_window != null)
88+ App.main_window.update_sensitivities.begin ();
89 file_operations_started ();
90 return true;
91 }
92
93=== modified file 'src/LocalBackend/LocalMedia.vala'
94--- src/LocalBackend/LocalMedia.vala 2016-04-29 15:37:31 +0000
95+++ src/LocalBackend/LocalMedia.vala 2016-05-14 04:57:26 +0000
96@@ -29,6 +29,23 @@
97 */
98
99 public class Noise.LocalMedia : Noise.Media {
100+ private File? _file = null;
101+ public override File file {
102+ get {
103+ if (_file == null) {
104+ var query = Database.query_field (rowid, connection, Database.Media.TABLE_NAME, "uri");
105+ if (query != null) {
106+ _file = File.new_for_uri (query.dup_string ());
107+ }
108+ }
109+ return _file;
110+ }
111+ set {
112+ Database.set_field (rowid, connection, Database.Media.TABLE_NAME, "uri", value.get_uri ());
113+ _file = value;
114+ }
115+ }
116+
117 private uint64? _file_size = null;
118 public override uint64 file_size {
119 get {
120@@ -435,7 +452,7 @@
121 var query = Database.query_field (rowid, connection, Database.Media.TABLE_NAME, field);
122 if (query != null) {
123 temp = query.dup_string ();
124- return _composer;
125+ return temp;
126 } else
127 return UNKNOWN;
128 }
129
130=== modified file 'src/Views/Wrappers/ViewWrapper.vala'
131--- src/Views/Wrappers/ViewWrapper.vala 2016-02-08 00:20:41 +0000
132+++ src/Views/Wrappers/ViewWrapper.vala 2016-05-14 04:57:26 +0000
133@@ -136,6 +136,7 @@
134
135 App.main_window.viewSelector.mode_changed.connect (view_selector_changed);
136 library.search_finished.connect (search_field_changed);
137+ library.file_operations_done.connect (update_visible_media);
138 }
139
140 /**
141
142=== modified file 'src/Widgets/InfoPanel.vala'
143--- src/Widgets/InfoPanel.vala 2016-02-08 00:20:41 +0000
144+++ src/Widgets/InfoPanel.vala 2016-05-14 04:57:26 +0000
145@@ -135,7 +135,7 @@
146 }
147
148 private void update_cover_art () {
149- var cover_icon = current_media.album_info.cover_icon;
150+ var cover_icon = (current_media != null) ? current_media.album_info.cover_icon : null;
151 if (cover_icon != null) {
152 coverArt.gicon = cover_icon;
153 } else {

Subscribers

People subscribed via source and target branches