Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
bb107c80
Commit
bb107c80
authored
Dec 23, 2015
by
Hugo Beauzée-Luyssen
Browse files
factory: FileSystem: Don't let createDirectory throw exceptions
parent
c7cf425c
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/discoverer/FsDiscoverer.cpp
View file @
bb107c80
...
...
@@ -56,16 +56,7 @@ bool FsDiscoverer::discover( const std::string &entryPoint )
return
true
;
}
// Otherwise, create a directory, and check it for modifications
std
::
shared_ptr
<
fs
::
IDirectory
>
fsDir
;
try
{
fsDir
=
m_fsFactory
->
createDirectory
(
entryPoint
);
}
catch
(
std
::
exception
&
ex
)
{
LOG_ERROR
(
"Failed to create an IDirectory for "
,
entryPoint
,
": "
,
ex
.
what
());
return
false
;
}
std
::
shared_ptr
<
fs
::
IDirectory
>
fsDir
=
m_fsFactory
->
createDirectory
(
entryPoint
);
if
(
fsDir
==
nullptr
)
{
LOG_ERROR
(
"Failed to create an IDirectory for "
,
entryPoint
);
...
...
@@ -89,6 +80,12 @@ void FsDiscoverer::reload()
for
(
const
auto
&
f
:
rootFolders
)
{
auto
folder
=
m_fsFactory
->
createDirectory
(
f
->
path
()
);
if
(
folder
==
nullptr
)
{
LOG_INFO
(
"Removing folder "
,
f
->
path
()
);
m_ml
->
deleteFolder
(
f
);
continue
;
}
if
(
folder
->
lastModificationDate
()
==
f
->
lastModificationDate
()
)
{
LOG_INFO
(
f
->
path
(),
" isn't modified"
);
...
...
@@ -137,6 +134,8 @@ bool FsDiscoverer::checkSubfolders( fs::IDirectory* folder, Folder* parentFolder
for
(
const
auto
&
subFolderPath
:
folder
->
dirs
()
)
{
auto
subFolder
=
m_fsFactory
->
createDirectory
(
subFolderPath
);
if
(
subFolder
==
nullptr
)
continue
;
auto
it
=
std
::
find_if
(
begin
(
subFoldersInDB
),
end
(
subFoldersInDB
),
[
subFolderPath
](
const
std
::
shared_ptr
<
IFolder
>&
f
)
{
return
f
->
path
()
==
subFolderPath
;
...
...
src/factory/FileSystem.cpp
View file @
bb107c80
...
...
@@ -23,6 +23,7 @@
#include
"factory/FileSystem.h"
#include
"filesystem/IDirectory.h"
#include
"filesystem/IFile.h"
#include
"logging/Logger.h"
#if defined(__linux__) || defined(__APPLE__)
# include "filesystem/unix/Directory.h"
...
...
@@ -44,9 +45,17 @@ std::shared_ptr<fs::IDirectory> FileSystemFactory::createDirectory( const std::s
const
auto
it
=
m_dirs
.
find
(
path
);
if
(
it
!=
end
(
m_dirs
)
)
return
it
->
second
;
auto
dir
=
std
::
make_shared
<
fs
::
Directory
>
(
path
);
m_dirs
[
path
]
=
dir
;
return
dir
;
try
{
auto
dir
=
std
::
make_shared
<
fs
::
Directory
>
(
path
);
m_dirs
[
path
]
=
dir
;
return
dir
;
}
catch
(
std
::
exception
&
ex
)
{
LOG_ERROR
(
"Failed to create fs::IDirectory for "
,
path
,
": "
,
ex
.
what
());
return
nullptr
;
}
}
std
::
unique_ptr
<
fs
::
IFile
>
FileSystemFactory
::
createFile
(
const
std
::
string
&
fileName
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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