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é GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Kubat
lektor
Validations
8a5e722a
Non vérifiée
Valider
8a5e722a
rédigé
Il y a 2 mois
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
REPO: Fix the repo-downloader with the updated NKDB
parent
bfe1187b
Branches
Branches contenant la validation
Aucune étiquette associée trouvée
2 requêtes de fusion
!205
misc debug and harderning, mostly related to repo syncing
,
!197
Draft: Refactor the whole code.
Modifications
2
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
lektor_repo/src/downloader.rs
+50
-53
50 ajouts, 53 suppressions
lektor_repo/src/downloader.rs
lektor_repo/src/lib.rs
+8
-8
8 ajouts, 8 suppressions
lektor_repo/src/lib.rs
avec
58 ajouts
et
61 suppressions
lektor_repo/src/downloader.rs
+
50
−
53
Voir le fichier @
8a5e722a
...
@@ -13,8 +13,8 @@ use kurisu_api::{
...
@@ -13,8 +13,8 @@ use kurisu_api::{
use
lektor_nkdb
::{
DatabaseStorage
,
KId
,
RemoteKId
,
UpdateHandler
};
use
lektor_nkdb
::{
DatabaseStorage
,
KId
,
RemoteKId
,
UpdateHandler
};
use
lektor_utils
::
config
::
LektorRepoConfig
;
use
lektor_utils
::
config
::
LektorRepoConfig
;
use
reqwest
::{
use
reqwest
::{
header
::{
self
,
HeaderName
,
HeaderValue
},
header
::{
self
,
HeaderName
,
HeaderValue
},
Client
,
Method
,
Request
,
RequestBuilder
,
Client
,
Method
,
Request
,
RequestBuilder
,
Url
,
Url
,
};
};
use
serde
::
de
::
DeserializeOwned
;
use
serde
::
de
::
DeserializeOwned
;
use
std
::
cmp
::
Ordering
;
use
std
::
cmp
::
Ordering
;
...
@@ -80,7 +80,8 @@ pub async fn download_kara<Storage: DatabaseStorage>(
...
@@ -80,7 +80,8 @@ pub async fn download_kara<Storage: DatabaseStorage>(
handle
:
&
UpdateHandler
<
'_
,
Storage
>
,
handle
:
&
UpdateHandler
<
'_
,
Storage
>
,
(
kid
,
rkid
,
sha256
):
(
KId
,
RemoteKId
,
SHA256
),
(
kid
,
rkid
,
sha256
):
(
KId
,
RemoteKId
,
SHA256
),
)
->
Result
<
()
>
{
)
->
Result
<
()
>
{
let
mut
stream
=
std
::
pin
::
pin!
(
stream
::
iter
(
let
mut
stream
=
std
::
pin
::
pin!
(
stream
::
iter
(
// Build the urls we will try
// Build the urls we will try
config
config
.urls
.urls
...
@@ -122,7 +123,8 @@ pub async fn download_kara<Storage: DatabaseStorage>(
...
@@ -122,7 +123,8 @@ pub async fn download_kara<Storage: DatabaseStorage>(
handle
.submit_kara
(
file
,
kid
,
sha256
)
.await
?
;
handle
.submit_kara
(
file
,
kid
,
sha256
)
.await
?
;
Ok
(())
Ok
(())
}
}
}));
})
);
loop
{
loop
{
if
let
Some
(
x
)
=
stream
.next
()
.await
{
if
let
Some
(
x
)
=
stream
.next
()
.await
{
...
@@ -148,18 +150,13 @@ async fn download_from_urls<T: DeserializeOwned>(urls: Vec<String>) -> Option<T>
...
@@ -148,18 +150,13 @@ async fn download_from_urls<T: DeserializeOwned>(urls: Vec<String>) -> Option<T>
.ok
()
?
;
.ok
()
?
;
if
r
.status
()
.is_success
()
{
if
r
.status
()
.is_success
()
{
match
r
.json
::
<
T
>
()
.await
{
r
.json
::
<
T
>
()
Ok
(
list
)
=>
{
.await
log
::
info!
(
"success fetching {url}, keeping it..."
);
.inspect
(|
_
|
log
::
info!
(
"success fetching {url}, keeping it..."
))
Some
(
list
)
.map_err
(|
e
|
log
::
info!
(
"error decoding data from {url} ({e}) skipping it..."
))
}
.ok
()
Err
(
e
)
=>
{
log
::
info!
(
"error decoding data from {url} ({e}) skipping it..."
);
None
}
}
}
else
{
}
else
{
log
::
info
!
(
log
::
warn
!
(
"error while fetching {url} ({}), skipping it..."
,
"error while fetching {url} ({}), skipping it..."
,
r
.text
()
.await
.unwrap_or
(
String
::
from
(
"unknown error"
))
r
.text
()
.await
.unwrap_or
(
String
::
from
(
"unknown error"
))
);
);
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
lektor_repo/src/lib.rs
+
8
−
8
Voir le fichier @
8a5e722a
...
@@ -4,11 +4,11 @@ mod downloader;
...
@@ -4,11 +4,11 @@ mod downloader;
mod
routes
;
mod
routes
;
use
crate
::
downloader
::
*
;
use
crate
::
downloader
::
*
;
use
anyhow
::{
Result
,
bail
};
use
anyhow
::{
bail
,
Result
};
use
futures
::
future
::
join_all
;
use
futures
::
future
::
join_all
;
use
kurisu_api
::{
use
kurisu_api
::{
v2
::{
Infos
,
Kara
,
KaraList
},
SHA256
,
SHA256
,
v2
::{
Infos
,
KaraList
},
};
};
use
lektor_nkdb
::{
DatabaseStorage
,
UpdateHandler
};
use
lektor_nkdb
::{
DatabaseStorage
,
UpdateHandler
};
use
lektor_nkdb
::{
KId
,
RemoteKId
};
use
lektor_nkdb
::{
KId
,
RemoteKId
};
...
@@ -76,17 +76,17 @@ impl Repo {
...
@@ -76,17 +76,17 @@ impl Repo {
vec!
[]
vec!
[]
}
}
}
}
.into_iter
()
.into_iter
();
let
updated_list
=
updated_list
.map
(|
kara
|
async
{
.map
(|
kara
|
async
{
let
remote_id
=
kara
.id
;
let
Kara
{
id
,
file_hash
,
filesize
,
..
}
=
kara
;
let
hash
=
kara
.file_hash
;
let
filesize
=
kara
.filesize
;
log
::
trace!
(
"got kara from {}: {kara:#?}"
,
repo_name
);
log
::
trace!
(
"got kara from {}: {kara:#?}"
,
repo_name
);
if
let
Some
((
kid
,
rkid
))
=
handler
.add_kara_v2
(
repo_name
,
kara
)
.await
{
if
let
Some
((
kid
,
rkid
))
=
handler
.add_kara_v2
(
repo_name
,
kara
)
.await
{
log
::
trace!
(
"got from {repo_name}: {kid} / {rkid} is new (and non-virtual) or had a file update"
);
log
::
trace!
(
"got from {repo_name}: {kid} / {rkid} is new (and non-virtual) or had a file update"
);
Some
((
kid
,
rkid
,
hash
,
filesize
))
Some
((
kid
,
rkid
,
file_
hash
,
filesize
))
}
else
{
}
else
{
log
::
trace!
(
"got from {repo_name}: kara {
remote_
id} is the same or only metadata got changed"
);
log
::
trace!
(
"got from {repo_name}: kara {id} is the same or only metadata got changed"
);
None
None
}
}
});
});
...
...
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