Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
lektor
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Kubat
lektor
Validations
8ef4e31c
Vérifiée
Valider
8ef4e31c
rédigé
5 years ago
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Timestamp check
parent
1d0e182f
Aucune branche associée trouvée
Branches contenant la validation
Aucune étiquette associée trouvée
Étiquettes contenant la validation
1 requête de fusion
!65
Resolve "Sync from kurisu"
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
src/net/downloader.c
+40
-3
40 ajouts, 3 suppressions
src/net/downloader.c
avec
40 ajouts
et
3 suppressions
src/net/downloader.c
+
40
−
3
Voir le fichier @
8ef4e31c
...
@@ -87,8 +87,7 @@ repo_free(struct lkt_repo *const repo)
...
@@ -87,8 +87,7 @@ repo_free(struct lkt_repo *const repo)
if
(
!
curl_init
)
if
(
!
curl_init
)
curl_global_cleanup
();
curl_global_cleanup
();
}
}
static
inline
int
int
safe_json_get_string
(
struct
json_object
*
jobj
,
const
char
*
key
,
char
*
content
,
const
size_t
len
)
safe_json_get_string
(
struct
json_object
*
jobj
,
const
char
*
key
,
char
*
content
,
const
size_t
len
)
{
{
const
char
*
got
;
const
char
*
got
;
...
@@ -101,7 +100,7 @@ safe_json_get_string(struct json_object *jobj, const char *key, char *content, c
...
@@ -101,7 +100,7 @@ safe_json_get_string(struct json_object *jobj, const char *key, char *content, c
return
0
;
return
0
;
}
}
int
static
inline
int
safe_json_get_int32
(
struct
json_object
*
json
,
const
char
*
key
,
int32_t
*
ret
)
safe_json_get_int32
(
struct
json_object
*
json
,
const
char
*
key
,
int32_t
*
ret
)
{
{
struct
json_object
*
field
;
struct
json_object
*
field
;
...
@@ -112,6 +111,28 @@ safe_json_get_int32(struct json_object *json, const char *key, int32_t *ret)
...
@@ -112,6 +111,28 @@ safe_json_get_int32(struct json_object *json, const char *key, int32_t *ret)
return
0
;
return
0
;
}
}
static
inline
long
get_digit_number
(
long
i
)
{
int
count
=
0
;
while
(
i
)
{
i
/=
10
;
++
count
;
}
return
count
;
}
int
safe_json_get_long
(
struct
json_object
*
json
,
const
char
*
key
,
long
*
ret
)
{
const
int
len
=
get_digit_number
(
LONG_MAX
);
char
content
[
len
],
*
endptr
,
err
;
if
(
safe_json_get_string
(
json
,
key
,
content
,
len
))
return
1
;
STRTOL
(
*
ret
,
content
,
endptr
,
err
);
return
err
;
}
int
int
repo_get_alljson_sync
(
struct
lkt_repo
*
const
repo
,
struct
json_object
**
json
)
repo_get_alljson_sync
(
struct
lkt_repo
*
const
repo
,
struct
json_object
**
json
)
{
{
...
@@ -347,6 +368,13 @@ repo_download_id_async(struct lkt_repo *const repo, const size_t id)
...
@@ -347,6 +368,13 @@ repo_download_id_async(struct lkt_repo *const repo, const size_t id)
/* Get all the kara, make them unavailable */
/* Get all the kara, make them unavailable */
static
inline
time_t
get_mtime
(
const
char
*
path
)
{
struct
stat
statbuf
;
return
(
stat
(
path
,
&
statbuf
)
==
-
1
)
?
0
:
statbuf
.
st_mtime
;
}
static
inline
void
static
inline
void
__handle_got_json
(
volatile
sqlite3
*
db
,
struct
lkt_repo
*
repo
,
struct
json_object
*
json
)
__handle_got_json
(
volatile
sqlite3
*
db
,
struct
lkt_repo
*
repo
,
struct
json_object
*
json
)
{
{
...
@@ -355,6 +383,7 @@ __handle_got_json(volatile sqlite3 *db, struct lkt_repo *repo, struct json_objec
...
@@ -355,6 +383,7 @@ __handle_got_json(volatile sqlite3 *db, struct lkt_repo *repo, struct json_objec
int32_t
integer
,
err
;
int32_t
integer
,
err
;
struct
kara
*
kara
;
struct
kara
*
kara
;
char
url
[
URL_MAX_LEN
];
char
url
[
URL_MAX_LEN
];
long
stamp
,
timestamp
;
RETURN_UNLESS
(
len
>
0
&&
json_object_get_array
(
json
),
"Json invalid or array empty"
,
NOTHING
);
RETURN_UNLESS
(
len
>
0
&&
json_object_get_array
(
json
),
"Json invalid or array empty"
,
NOTHING
);
LOG_INFO_SCT
(
"REPO"
,
"Starting to process json for repo %s"
,
repo
->
name
);
LOG_INFO_SCT
(
"REPO"
,
"Starting to process json for repo %s"
,
repo
->
name
);
...
@@ -380,6 +409,14 @@ __handle_got_json(volatile sqlite3 *db, struct lkt_repo *repo, struct json_objec
...
@@ -380,6 +409,14 @@ __handle_got_json(volatile sqlite3 *db, struct lkt_repo *repo, struct json_objec
kara
->
filename
[
PATH_MAX
-
1
]
=
0
;
kara
->
filename
[
PATH_MAX
-
1
]
=
0
;
LOG_INFO_SCT
(
"REPO"
,
"Crafted filename is '%s'"
,
kara
->
filename
);
LOG_INFO_SCT
(
"REPO"
,
"Crafted filename is '%s'"
,
kara
->
filename
);
if
(
safe_json_get_long
(
kara_json
,
"unix_timestamp"
,
&
timestamp
))
continue
;
stamp
=
get_mtime
(
kara
->
filename
);
if
(
stamp
>
timestamp
)
{
LOG_INFO_SCT
(
"REPO"
,
"Ignore kara '%ld', last timestamp was %ld, new is %ld"
,
kara
->
id
,
stamp
,
timestamp
);
continue
;
}
err
|=
safe_json_get_string
(
kara_json
,
"song_name"
,
kara
->
mdt
.
song_name
,
LEKTOR_TAG_MAX
);
err
|=
safe_json_get_string
(
kara_json
,
"song_name"
,
kara
->
mdt
.
song_name
,
LEKTOR_TAG_MAX
);
err
|=
safe_json_get_string
(
kara_json
,
"source_name"
,
kara
->
mdt
.
source_name
,
LEKTOR_TAG_MAX
);
err
|=
safe_json_get_string
(
kara_json
,
"source_name"
,
kara
->
mdt
.
source_name
,
LEKTOR_TAG_MAX
);
err
|=
safe_json_get_string
(
kara_json
,
"category"
,
kara
->
mdt
.
category
,
LEKTOR_TAG_MAX
);
err
|=
safe_json_get_string
(
kara_json
,
"category"
,
kara
->
mdt
.
category
,
LEKTOR_TAG_MAX
);
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter