Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
apk-tools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
60
Issues
60
List
Boards
Labels
Service Desk
Milestones
Merge Requests
16
Merge Requests
16
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpine
apk-tools
Commits
ba76c5f4
Commit
ba76c5f4
authored
Jul 15, 2009
by
Timo Teräs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cache: make cache cleaning work again properly
parent
a7c5fda4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
24 deletions
+32
-24
src/apk_package.h
src/apk_package.h
+2
-0
src/cache.c
src/cache.c
+27
-24
src/package.c
src/package.c
+3
-0
No files found.
src/apk_package.h
View file @
ba76c5f4
...
...
@@ -84,6 +84,8 @@ struct apk_package *apk_pkg_new(void);
struct
apk_package
*
apk_pkg_read
(
struct
apk_database
*
db
,
const
char
*
name
);
void
apk_pkg_free
(
struct
apk_package
*
pkg
);
int
apk_pkg_parse_name
(
apk_blob_t
apkname
,
apk_blob_t
*
name
,
apk_blob_t
*
version
);
int
apk_pkg_add_info
(
struct
apk_database
*
db
,
struct
apk_package
*
pkg
,
char
field
,
apk_blob_t
value
);
int
apk_pkg_get_state
(
struct
apk_package
*
pkg
);
...
...
src/cache.c
View file @
ba76c5f4
...
...
@@ -17,6 +17,7 @@
#include "apk_applet.h"
#include "apk_database.h"
#include "apk_state.h"
#include "apk_package.h"
#define CACHE_CLEAN BIT(0)
#define CACHE_DOWNLOAD BIT(1)
...
...
@@ -70,7 +71,8 @@ static int cache_clean(struct apk_database *db)
struct
dirent
*
de
;
char
path
[
256
],
csum
[
APK_CACHE_CSUM_BYTES
];
int
delete
,
i
;
apk_blob_t
b
;
apk_blob_t
b
,
bname
,
bver
;
struct
apk_name
*
name
;
snprintf
(
path
,
sizeof
(
path
),
"%s/%s"
,
db
->
root
,
db
->
cache_dir
);
if
(
chdir
(
path
)
!=
0
)
...
...
@@ -85,35 +87,36 @@ static int cache_clean(struct apk_database *db)
continue
;
delete
=
TRUE
;
do
{
if
(
strlen
(
de
->
d_name
)
<=
APK_CACHE_CSUM_BYTES
*
2
+
2
)
break
;
b
=
APK_BLOB_PTR_LEN
(
de
->
d_name
,
APK_CACHE_CSUM_BYTES
*
2
);
b
=
APK_BLOB_STR
(
de
->
d_name
);
apk_blob_pull_hexdump
(
&
b
,
APK_BLOB_BUF
(
csum
));
if
(
APK_BLOB_IS_NULL
(
b
))
break
;
if
(
de
->
d_name
[
APK_CACHE_CSUM_BYTES
*
2
]
!=
'.'
)
break
;
if
(
strcmp
(
&
de
->
d_name
[
APK_CACHE_CSUM_BYTES
*
2
+
1
],
apk_index_gz
)
==
0
)
{
apk_blob_pull_char
(
&
b
,
'.'
);
if
(
apk_blob_compare
(
b
,
APK_BLOB_STR
(
apk_index_gz
))
==
0
)
{
/* Index - check for matching repository */
for
(
i
=
0
;
i
<
db
->
num_repos
;
i
++
)
for
(
i
=
0
;
i
<
db
->
num_repos
;
i
++
)
{
if
(
memcmp
(
db
->
repos
[
i
].
csum
.
data
,
csum
,
APK_CACHE_CSUM_BYTES
)
==
0
)
break
;
delete
=
(
i
>=
db
->
num_repos
);
}
else
{
csum
,
APK_CACHE_CSUM_BYTES
)
!=
0
)
continue
;
delete
=
0
;
break
;
}
}
else
if
(
b
.
len
>
4
&&
memcmp
(
b
.
ptr
+
b
.
len
-
4
,
".apk"
,
4
)
==
0
)
{
/* Package - search for it */
#if 0
pkg = apk_db_get_pkg(db, csum);
if (pkg == NULL)
if
(
apk_pkg_parse_name
(
b
,
&
bname
,
&
bver
)
<
0
)
break
;
snprintf(path, sizeof(path), "%s-%s.apk",
pkg->name->name, pkg->version);
delete = strcmp(&de->d_name[sizeof(csum_t)*2+1],
path);
#endif
//#warning FIXME - need to check if cache file is valid - look up using name, check csum
name
=
apk_db_get_name
(
db
,
bname
);
if
(
name
==
NULL
||
name
->
pkgs
==
NULL
)
break
;
for
(
i
=
0
;
i
<
name
->
pkgs
->
num
;
i
++
)
{
struct
apk_package
*
pkg
=
name
->
pkgs
->
item
[
i
];
if
(
memcmp
(
pkg
->
csum
.
data
,
csum
,
APK_CACHE_CSUM_BYTES
)
!=
0
)
continue
;
delete
=
0
;
break
;
}
}
}
while
(
0
);
...
...
src/package.c
View file @
ba76c5f4
...
...
@@ -43,6 +43,9 @@ int apk_pkg_parse_name(apk_blob_t apkname,
{
int
i
,
dash
=
0
;
if
(
APK_BLOB_IS_NULL
(
apkname
))
return
-
1
;
for
(
i
=
apkname
.
len
-
2
;
i
>=
0
;
i
--
)
{
if
(
apkname
.
ptr
[
i
]
!=
'-'
)
continue
;
...
...
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