Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
96f4394d
Commit
96f4394d
authored
Feb 26, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/update/Archive: pass ArchiveFile to Song constructor
Don't open the ZIP file again and again for each song file.
parent
35567e65
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
Archive.cxx
src/db/update/Archive.cxx
+10
-7
Walk.hxx
src/db/update/Walk.hxx
+3
-1
No files found.
src/db/update/Archive.cxx
View file @
96f4394d
...
@@ -61,7 +61,8 @@ LockFindSong(Directory &directory, const char *name)
...
@@ -61,7 +61,8 @@ LockFindSong(Directory &directory, const char *name)
}
}
void
void
UpdateWalk
::
UpdateArchiveTree
(
Directory
&
directory
,
const
char
*
name
)
UpdateWalk
::
UpdateArchiveTree
(
ArchiveFile
&
archive
,
Directory
&
directory
,
const
char
*
name
)
{
{
const
char
*
tmp
=
strchr
(
name
,
'/'
);
const
char
*
tmp
=
strchr
(
name
,
'/'
);
if
(
tmp
)
{
if
(
tmp
)
{
...
@@ -72,7 +73,7 @@ UpdateWalk::UpdateArchiveTree(Directory &directory, const char *name)
...
@@ -72,7 +73,7 @@ UpdateWalk::UpdateArchiveTree(Directory &directory, const char *name)
subdir
->
device
=
DEVICE_INARCHIVE
;
subdir
->
device
=
DEVICE_INARCHIVE
;
//create directories first
//create directories first
UpdateArchiveTree
(
*
subdir
,
tmp
+
1
);
UpdateArchiveTree
(
archive
,
*
subdir
,
tmp
+
1
);
}
else
{
}
else
{
if
(
StringIsEmpty
(
name
))
{
if
(
StringIsEmpty
(
name
))
{
LogWarning
(
update_domain
,
LogWarning
(
update_domain
,
...
@@ -83,7 +84,7 @@ UpdateWalk::UpdateArchiveTree(Directory &directory, const char *name)
...
@@ -83,7 +84,7 @@ UpdateWalk::UpdateArchiveTree(Directory &directory, const char *name)
//add file
//add file
Song
*
song
=
LockFindSong
(
directory
,
name
);
Song
*
song
=
LockFindSong
(
directory
,
name
);
if
(
song
==
nullptr
)
{
if
(
song
==
nullptr
)
{
song
=
Song
::
LoadF
ile
(
storag
e
,
name
,
directory
);
song
=
Song
::
LoadF
romArchive
(
archiv
e
,
name
,
directory
);
if
(
song
!=
nullptr
)
{
if
(
song
!=
nullptr
)
{
{
{
const
ScopeDatabaseLock
protect
;
const
ScopeDatabaseLock
protect
;
...
@@ -100,16 +101,18 @@ UpdateWalk::UpdateArchiveTree(Directory &directory, const char *name)
...
@@ -100,16 +101,18 @@ UpdateWalk::UpdateArchiveTree(Directory &directory, const char *name)
class
UpdateArchiveVisitor
final
:
public
ArchiveVisitor
{
class
UpdateArchiveVisitor
final
:
public
ArchiveVisitor
{
UpdateWalk
&
walk
;
UpdateWalk
&
walk
;
ArchiveFile
&
archive
;
Directory
*
directory
;
Directory
*
directory
;
public
:
public
:
UpdateArchiveVisitor
(
UpdateWalk
&
_walk
,
Directory
*
_directory
)
UpdateArchiveVisitor
(
UpdateWalk
&
_walk
,
ArchiveFile
&
_archive
,
:
walk
(
_walk
),
directory
(
_directory
)
{}
Directory
*
_directory
)
:
walk
(
_walk
),
archive
(
_archive
),
directory
(
_directory
)
{}
virtual
void
VisitArchiveEntry
(
const
char
*
path_utf8
)
override
{
virtual
void
VisitArchiveEntry
(
const
char
*
path_utf8
)
override
{
FormatDebug
(
update_domain
,
FormatDebug
(
update_domain
,
"adding archive file: %s"
,
path_utf8
);
"adding archive file: %s"
,
path_utf8
);
walk
.
UpdateArchiveTree
(
*
directory
,
path_utf8
);
walk
.
UpdateArchiveTree
(
archive
,
*
directory
,
path_utf8
);
}
}
};
};
...
@@ -165,7 +168,7 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
...
@@ -165,7 +168,7 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
directory
->
mtime
=
info
.
mtime
;
directory
->
mtime
=
info
.
mtime
;
UpdateArchiveVisitor
visitor
(
*
this
,
directory
);
UpdateArchiveVisitor
visitor
(
*
this
,
*
file
,
directory
);
file
->
Visit
(
visitor
);
file
->
Visit
(
visitor
);
file
->
Close
();
file
->
Close
();
}
}
...
...
src/db/update/Walk.hxx
View file @
96f4394d
...
@@ -30,6 +30,7 @@ struct stat;
...
@@ -30,6 +30,7 @@ struct stat;
struct
StorageFileInfo
;
struct
StorageFileInfo
;
struct
Directory
;
struct
Directory
;
struct
ArchivePlugin
;
struct
ArchivePlugin
;
class
ArchiveFile
;
class
Storage
;
class
Storage
;
class
ExcludeList
;
class
ExcludeList
;
...
@@ -101,7 +102,8 @@ private:
...
@@ -101,7 +102,8 @@ private:
#ifdef ENABLE_ARCHIVE
#ifdef ENABLE_ARCHIVE
void
UpdateArchiveTree
(
Directory
&
parent
,
const
char
*
name
);
void
UpdateArchiveTree
(
ArchiveFile
&
archive
,
Directory
&
parent
,
const
char
*
name
);
bool
UpdateArchiveFile
(
Directory
&
directory
,
bool
UpdateArchiveFile
(
Directory
&
directory
,
const
char
*
name
,
const
char
*
suffix
,
const
char
*
name
,
const
char
*
suffix
,
...
...
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