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
9 years ago
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)
}
void
UpdateWalk
::
UpdateArchiveTree
(
Directory
&
directory
,
const
char
*
name
)
UpdateWalk
::
UpdateArchiveTree
(
ArchiveFile
&
archive
,
Directory
&
directory
,
const
char
*
name
)
{
const
char
*
tmp
=
strchr
(
name
,
'/'
);
if
(
tmp
)
{
...
...
@@ -72,7 +73,7 @@ UpdateWalk::UpdateArchiveTree(Directory &directory, const char *name)
subdir
->
device
=
DEVICE_INARCHIVE
;
//create directories first
UpdateArchiveTree
(
*
subdir
,
tmp
+
1
);
UpdateArchiveTree
(
archive
,
*
subdir
,
tmp
+
1
);
}
else
{
if
(
StringIsEmpty
(
name
))
{
LogWarning
(
update_domain
,
...
...
@@ -83,7 +84,7 @@ UpdateWalk::UpdateArchiveTree(Directory &directory, const char *name)
//add file
Song
*
song
=
LockFindSong
(
directory
,
name
);
if
(
song
==
nullptr
)
{
song
=
Song
::
LoadF
ile
(
storag
e
,
name
,
directory
);
song
=
Song
::
LoadF
romArchive
(
archiv
e
,
name
,
directory
);
if
(
song
!=
nullptr
)
{
{
const
ScopeDatabaseLock
protect
;
...
...
@@ -100,16 +101,18 @@ UpdateWalk::UpdateArchiveTree(Directory &directory, const char *name)
class
UpdateArchiveVisitor
final
:
public
ArchiveVisitor
{
UpdateWalk
&
walk
;
ArchiveFile
&
archive
;
Directory
*
directory
;
public
:
UpdateArchiveVisitor
(
UpdateWalk
&
_walk
,
Directory
*
_directory
)
:
walk
(
_walk
),
directory
(
_directory
)
{}
UpdateArchiveVisitor
(
UpdateWalk
&
_walk
,
ArchiveFile
&
_archive
,
Directory
*
_directory
)
:
walk
(
_walk
),
archive
(
_archive
),
directory
(
_directory
)
{}
virtual
void
VisitArchiveEntry
(
const
char
*
path_utf8
)
override
{
FormatDebug
(
update_domain
,
"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,
directory
->
mtime
=
info
.
mtime
;
UpdateArchiveVisitor
visitor
(
*
this
,
directory
);
UpdateArchiveVisitor
visitor
(
*
this
,
*
file
,
directory
);
file
->
Visit
(
visitor
);
file
->
Close
();
}
...
...
This diff is collapsed.
Click to expand it.
src/db/update/Walk.hxx
View file @
96f4394d
...
...
@@ -30,6 +30,7 @@ struct stat;
struct
StorageFileInfo
;
struct
Directory
;
struct
ArchivePlugin
;
class
ArchiveFile
;
class
Storage
;
class
ExcludeList
;
...
...
@@ -101,7 +102,8 @@ private:
#ifdef ENABLE_ARCHIVE
void
UpdateArchiveTree
(
Directory
&
parent
,
const
char
*
name
);
void
UpdateArchiveTree
(
ArchiveFile
&
archive
,
Directory
&
parent
,
const
char
*
name
);
bool
UpdateArchiveFile
(
Directory
&
directory
,
const
char
*
name
,
const
char
*
suffix
,
...
...
This diff is collapsed.
Click to expand it.
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