Merge lp:~jpakkane/mediascanner2/nomedia into lp:mediascanner2

Proposed by Jussi Pakkanen
Status: Merged
Approved by: James Henstridge
Approved revision: 230
Merged at revision: 232
Proposed branch: lp:~jpakkane/mediascanner2/nomedia
Merge into: lp:mediascanner2
Prerequisite: lp:~jpakkane/mediascanner2/skipoptical
Diff against target: 108 lines (+38/-0)
6 files modified
src/daemon/Scanner.cc (+6/-0)
src/daemon/SubtreeWatcher.cc (+5/-0)
src/daemon/scannerdaemon.cc (+4/-0)
src/daemon/util.cc (+15/-0)
src/daemon/util.h (+1/-0)
test/test_util.cc (+7/-0)
To merge this branch: bzr merge lp:~jpakkane/mediascanner2/nomedia
Reviewer Review Type Date Requested Status
James Henstridge Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+218358@code.launchpad.net

Commit message

Add support for .nomedia files to prevent chosen subtrees from being scanned.

Description of the change

Add support for .nomedia files to prevent chosen subtrees from being scanned.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
James Henstridge (jamesh) wrote :

Looks good.

review: Approve
Revision history for this message
James Henstridge (jamesh) wrote :

Looks like this has conflicts against trunk.

lp:~jpakkane/mediascanner2/nomedia updated
231. By Jussi Pakkanen

Merged trunk.

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

Conflict fixed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/daemon/Scanner.cc'
2--- src/daemon/Scanner.cc 2014-05-05 09:19:17 +0000
3+++ src/daemon/Scanner.cc 2014-05-14 11:58:12 +0000
4@@ -77,6 +77,12 @@
5 p->dir.reset();
6 continue;
7 }
8+ if(has_scanblock(p->curdir)) {
9+ fprintf(stderr, "Directory %s has a scan block file, skipping it.\n",
10+ p->curdir.c_str());
11+ p->dir.reset();
12+ continue;
13+ }
14 printf("In subdir %s\n", p->curdir.c_str());
15 }
16
17
18=== modified file 'src/daemon/SubtreeWatcher.cc'
19--- src/daemon/SubtreeWatcher.cc 2014-03-21 11:01:31 +0000
20+++ src/daemon/SubtreeWatcher.cc 2014-05-14 11:58:12 +0000
21@@ -101,6 +101,11 @@
22 root.c_str(), __PRETTY_FUNCTION__);
23 return;
24 }
25+ if(has_scanblock(root)) {
26+ fprintf(stderr, "Directory %s has a scan block file, skipping it.\n",
27+ root.c_str());
28+ return;
29+ }
30 if(p->str2wd.find(root) != p->str2wd.end())
31 return;
32 unique_ptr<DIR, int(*)(DIR*)> dir(opendir(root.c_str()), closedir);
33
34=== modified file 'src/daemon/scannerdaemon.cc'
35--- src/daemon/scannerdaemon.cc 2014-05-08 10:17:57 +0000
36+++ src/daemon/scannerdaemon.cc 2014-05-14 11:58:12 +0000
37@@ -150,6 +150,10 @@
38 fprintf(stderr, "Directory %s looks like an optical disc, skipping it.\n", dir.c_str());
39 return;
40 }
41+ if(has_scanblock(dir)) {
42+ fprintf(stderr, "Directory %s has a scan block file, skipping it.\n", dir.c_str());
43+ return;
44+ }
45 unique_ptr<SubtreeWatcher> sw(new SubtreeWatcher(*store.get(), *extractor.get(), invalidator));
46 store->restoreItems(dir);
47 store->pruneDeleted();
48
49=== modified file 'src/daemon/util.cc'
50--- src/daemon/util.cc 2014-04-09 13:25:51 +0000
51+++ src/daemon/util.cc 2014-05-14 11:58:12 +0000
52@@ -35,6 +35,17 @@
53 return S_ISDIR(statbuf.st_mode) ;
54 }
55
56+static bool file_exists(const string &path) {
57+ struct stat statbuf;
58+ if(stat(path.c_str(), &statbuf) < 0) {
59+ if(errno != ENOENT) {
60+ printf("Error while trying to determine state of file %s: %s\n", path.c_str(), strerror(errno));
61+ }
62+ return false;
63+ }
64+ return S_ISREG(statbuf.st_mode) ;
65+}
66+
67 bool is_rootlike(const string &path) {
68 string s1 = path + "/usr";
69 string s2 = path + "/var";
70@@ -49,3 +60,7 @@
71 string bluray = path + "/BDMV";
72 return (dir_exists(dvd1) && dir_exists(dvd2)) || dir_exists(bluray);
73 }
74+
75+bool has_scanblock(const std::string &path) {
76+ return file_exists(path + "/.nomedia");
77+}
78
79=== modified file 'src/daemon/util.h'
80--- src/daemon/util.h 2014-04-09 13:25:51 +0000
81+++ src/daemon/util.h 2014-05-14 11:58:12 +0000
82@@ -24,5 +24,6 @@
83
84 bool is_rootlike(const std::string &path);
85 bool is_optical_disc(const std::string &path);
86+bool has_scanblock(const std::string &path);
87
88 #endif
89
90=== added directory 'test/noscan'
91=== added file 'test/noscan/.nomedia'
92=== modified file 'test/test_util.cc'
93--- test/test_util.cc 2014-05-02 08:53:16 +0000
94+++ test/test_util.cc 2014-05-14 11:58:12 +0000
95@@ -42,6 +42,13 @@
96 ASSERT_FALSE(is_optical_disc(nodisc_root));
97 }
98
99+TEST_F(UtilTest, scanblock) {
100+ std::string noblock_root(SOURCE_DIR "/media");
101+ std::string block_root(SOURCE_DIR "/noscan");
102+ ASSERT_TRUE(has_scanblock(block_root));
103+ ASSERT_FALSE(has_scanblock(noblock_root));
104+}
105+
106 int main(int argc, char **argv) {
107 ::testing::InitGoogleTest(&argc, argv);
108 return RUN_ALL_TESTS();

Subscribers

People subscribed via source and target branches