Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
c49bb74e
Commit
c49bb74e
authored
Dec 15, 2015
by
Hugo Beauzée-Luyssen
Browse files
FsDiscoverer: Don't pass shared_ptr when no lifetime management is required
parent
d37cd870
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/MediaLibrary.cpp
View file @
c49bb74e
...
...
@@ -204,7 +204,7 @@ MediaPtr MediaLibrary::file( const std::string& path )
return
Media
::
fetch
(
m_dbConnection
.
get
(),
req
,
path
);
}
std
::
shared_ptr
<
Media
>
MediaLibrary
::
addFile
(
const
std
::
string
&
path
,
Folder
Ptr
parentFolder
)
std
::
shared_ptr
<
Media
>
MediaLibrary
::
addFile
(
const
std
::
string
&
path
,
Folder
*
parentFolder
)
{
LOG_INFO
(
"Adding "
,
path
);
std
::
unique_ptr
<
fs
::
IFile
>
file
;
...
...
src/MediaLibrary.h
View file @
c49bb74e
...
...
@@ -39,6 +39,7 @@ class Media;
class
Movie
;
class
Show
;
class
Device
;
class
Folder
;
class
MediaLibrary
:
public
IMediaLibrary
{
...
...
@@ -53,7 +54,7 @@ class MediaLibrary : public IMediaLibrary
virtual
std
::
vector
<
MediaPtr
>
audioFiles
()
override
;
virtual
std
::
vector
<
MediaPtr
>
videoFiles
()
override
;
virtual
MediaPtr
file
(
const
std
::
string
&
path
)
override
;
std
::
shared_ptr
<
Media
>
addFile
(
const
std
::
string
&
path
,
Folder
Ptr
parentFolder
);
std
::
shared_ptr
<
Media
>
addFile
(
const
std
::
string
&
path
,
Folder
*
parentFolder
);
virtual
bool
deleteFile
(
const
Media
*
file
);
virtual
FolderPtr
folder
(
const
std
::
string
&
path
)
override
;
...
...
src/discoverer/FsDiscoverer.cpp
View file @
c49bb74e
...
...
@@ -83,8 +83,8 @@ bool FsDiscoverer::discover( const std::string &entryPoint )
LOG_INFO
(
"Creating new device in DB "
,
deviceFs
->
uuid
()
);
device
=
Device
::
create
(
m_dbConn
,
deviceFs
->
uuid
(),
deviceFs
->
isRemovable
()
);
}
checkFiles
(
fsDir
.
get
(),
f
);
checkSubfolders
(
fsDir
.
get
(),
f
,
blist
);
checkFiles
(
fsDir
.
get
(),
f
.
get
()
);
checkSubfolders
(
fsDir
.
get
(),
f
.
get
()
,
blist
);
f
->
setLastModificationDate
(
fsDir
->
lastModificationDate
()
);
return
true
;
}
...
...
@@ -102,13 +102,13 @@ void FsDiscoverer::reload()
auto
folder
=
m_fsFactory
->
createDirectory
(
f
->
path
()
);
if
(
folder
->
lastModificationDate
()
==
f
->
lastModificationDate
()
)
continue
;
checkSubfolders
(
folder
.
get
(),
f
,
blist
);
checkFiles
(
folder
.
get
(),
f
);
checkSubfolders
(
folder
.
get
(),
f
.
get
()
,
blist
);
checkFiles
(
folder
.
get
(),
f
.
get
()
);
f
->
setLastModificationDate
(
folder
->
lastModificationDate
()
);
}
}
bool
FsDiscoverer
::
checkSubfolders
(
fs
::
IDirectory
*
folder
,
Folder
Ptr
parentFolder
,
const
std
::
vector
<
std
::
shared_ptr
<
Folder
>>
blacklist
)
bool
FsDiscoverer
::
checkSubfolders
(
fs
::
IDirectory
*
folder
,
Folder
*
parentFolder
,
const
std
::
vector
<
std
::
shared_ptr
<
Folder
>>
blacklist
)
{
// From here we can have:
// - New subfolder(s)
...
...
@@ -142,8 +142,8 @@ bool FsDiscoverer::checkSubfolders( fs::IDirectory* folder, FolderPtr parentFold
LOG_INFO
(
"New folder detected: "
,
subFolderPath
);
// Force a scan by setting lastModificationDate to 0
auto
f
=
Folder
::
create
(
m_dbConn
,
subFolder
->
path
(),
0
,
subFolder
->
isRemovable
(),
parentFolder
->
id
()
);
checkFiles
(
subFolder
.
get
(),
f
);
checkSubfolders
(
subFolder
.
get
(),
f
,
blacklist
);
checkFiles
(
subFolder
.
get
(),
f
.
get
()
);
checkSubfolders
(
subFolder
.
get
(),
f
.
get
()
,
blacklist
);
f
->
setLastModificationDate
(
subFolder
->
lastModificationDate
()
);
continue
;
}
...
...
@@ -157,8 +157,8 @@ bool FsDiscoverer::checkSubfolders( fs::IDirectory* folder, FolderPtr parentFold
continue
;
}
// This folder was modified, let's recurse
checkSubfolders
(
subFolder
.
get
(),
folderInDb
,
blacklist
);
checkFiles
(
subFolder
.
get
(),
folderInDb
);
checkSubfolders
(
subFolder
.
get
(),
folderInDb
.
get
()
,
blacklist
);
checkFiles
(
subFolder
.
get
(),
folderInDb
.
get
()
);
folderInDb
->
setLastModificationDate
(
subFolder
->
lastModificationDate
()
);
subFoldersInDB
.
erase
(
it
);
}
...
...
@@ -171,7 +171,7 @@ bool FsDiscoverer::checkSubfolders( fs::IDirectory* folder, FolderPtr parentFold
return
true
;
}
void
FsDiscoverer
::
checkFiles
(
fs
::
IDirectory
*
folder
,
Folder
Ptr
parentFolder
)
void
FsDiscoverer
::
checkFiles
(
fs
::
IDirectory
*
folder
,
Folder
*
parentFolder
)
{
LOG_INFO
(
"Checking file in "
,
folder
->
path
()
);
static
const
std
::
string
req
=
"SELECT * FROM "
+
policy
::
MediaTable
::
Name
...
...
src/discoverer/FsDiscoverer.h
View file @
c49bb74e
...
...
@@ -39,8 +39,8 @@ public:
virtual
void
reload
()
override
;
private:
bool
checkSubfolders
(
fs
::
IDirectory
*
folder
,
Folder
Ptr
parentFolder
,
const
std
::
vector
<
std
::
shared_ptr
<
Folder
>
>
blacklist
);
void
checkFiles
(
fs
::
IDirectory
*
folder
,
Folder
Ptr
parentFolder
);
bool
checkSubfolders
(
fs
::
IDirectory
*
folder
,
Folder
*
parentFolder
,
const
std
::
vector
<
std
::
shared_ptr
<
Folder
>
>
blacklist
);
void
checkFiles
(
fs
::
IDirectory
*
folder
,
Folder
*
parentFolder
);
std
::
vector
<
std
::
shared_ptr
<
Folder
>>
blacklist
()
const
;
bool
isBlacklisted
(
const
std
::
string
&
path
,
const
std
::
vector
<
std
::
shared_ptr
<
Folder
>>&
blacklist
)
const
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment