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
9bf28404
Vérifiée
Valider
9bf28404
rédigé
2 mars 2023
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
REPO: Make a kara unavailable when we download it
parent
542198aa
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
3
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
src/rust/lektor_db/src/connexion.rs
+24
-2
24 ajouts, 2 suppressions
src/rust/lektor_db/src/connexion.rs
src/rust/lektor_db/src/models.rs
+1
-1
1 ajout, 1 suppression
src/rust/lektor_db/src/models.rs
src/rust/lektor_repo/src/download.rs
+29
-11
29 ajouts, 11 suppressions
src/rust/lektor_repo/src/download.rs
avec
54 ajouts
et
14 suppressions
src/rust/lektor_db/src/connexion.rs
+
24
−
2
Voir le fichier @
9bf28404
...
@@ -212,8 +212,30 @@ impl LktDatabaseConnection {
...
@@ -212,8 +212,30 @@ impl LktDatabaseConnection {
})
})
}
}
pub
fn
make_kara_available
<
'a
>
(
&
mut
self
,
remote_id
:
RemoteKaraId
)
->
LktDatabaseResult
<
()
>
{
/// Makes a kara avilable, set the avail flag to `true` or `false` depending on the passed
todo!
()
/// flag. If the operation changed nothing, don't raise an error.
pub
fn
make_kara_available
<
'a
>
(
&
mut
self
,
remote_id
:
RemoteKaraId
,
flag
:
bool
,
)
->
LktDatabaseResult
<
()
>
{
let
RemoteKaraId
{
repo_id
:
rid
,
repo_kara_id
:
rkid
,
}
=
remote_id
;
self
.sqlite
.exclusive_transaction
(|
c
|
{
let
local_kara_id
:
i64
=
with_dsl!
(
repo_kara
=>
repo_kara
.select
(
local_kara_id
)
.filter
(
repo_id
.eq
(
rid
)
.and
(
repo_kara_id
.eq
(
rkid
)))
.first
(
c
)
?
);
with_dsl!
(
kara
=>
diesel
::
update
(
kara
)
.filter
(
id
.eq
(
local_kara_id
))
.set
(
is_dl
.eq
(
flag
))
.execute
(
c
)
?
);
Ok
(())
})
}
}
/// Create a series of models from a kara signature from Kurisu's V1 API.
/// Create a series of models from a kara signature from Kurisu's V1 API.
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/rust/lektor_db/src/models.rs
+
1
−
1
Voir le fichier @
9bf28404
...
@@ -18,7 +18,7 @@ pub struct KaraId {
...
@@ -18,7 +18,7 @@ pub struct KaraId {
pub
local_kara_id
:
i64
,
pub
local_kara_id
:
i64
,
}
}
#[derive(Debug,
Queryable,
Selectable)]
#[derive(Debug,
Queryable,
Selectable
,
Clone,
Copy
)]
#[diesel(table_name
=
repo_kara)]
#[diesel(table_name
=
repo_kara)]
pub
struct
RemoteKaraId
{
pub
struct
RemoteKaraId
{
pub
repo_id
:
i64
,
pub
repo_id
:
i64
,
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/rust/lektor_repo/src/download.rs
+
29
−
11
Voir le fichier @
9bf28404
...
@@ -225,24 +225,42 @@ impl Download {
...
@@ -225,24 +225,42 @@ impl Download {
search_urls
:
&
[
&
str
],
search_urls
:
&
[
&
str
],
dest
:
impl
AsRef
<
Path
>
,
dest
:
impl
AsRef
<
Path
>
,
)
{
)
{
let
(
dest
,
name
,
db
)
=
(
dest
.as_ref
(),
name
.as_ref
(),
self
.db
.clone
());
macro_rules!
make_kara_available
{
if
let
Err
(
err
)
=
(
$db
:
expr
,
$id
:
expr
,
$flag
:
expr
)
=>
{{
Download
::
download_kara
(
db
.clone
(),
api
,
search_urls
,
repo_id
,
repo_kara_id
,
dest
)
.await
let
mut
db
=
$db
.lock
()
.expect
(
"failed to lock the database..."
);
{
if
let
Err
(
err
)
=
db
.make_kara_available
(
$id
,
$flag
)
{
log
::
error!
(
target
:
"REPO"
,
"failed to download file `{}` for kara {repo_kara_id}: {err}"
,
dest
.to_string_lossy
());
log
::
error!
(
target
:
"REPO"
,
"failed to make kara `{repo_kara_id}` from {} {}: {err}"
,
name
.as_ref
(),
either!
(
$flag
=>
"available"
;
"unavailable"
)
);
return
;
return
;
}
}
let
mut
db
=
db
.lock
()
.expect
(
"failed to lock the database..."
);
}};
let
remote_id
=
RemoteKaraId
{
}
let
(
remote_id
,
db
,
dest
)
=
(
RemoteKaraId
{
repo_id
,
repo_id
,
repo_kara_id
,
repo_kara_id
,
};
},
if
let
Err
(
err
)
=
db
.make_kara_available
(
remote_id
)
{
self
.db
.clone
(),
log
::
error!
(
target
:
"REPO"
,
"failed to make kara `{repo_kara_id}` from {name} available: {err}"
);
dest
.as_ref
(),
);
make_kara_available!
(
db
,
remote_id
,
false
);
if
let
Err
(
err
)
=
Download
::
download_kara
(
db
.clone
(),
api
,
search_urls
,
repo_id
,
repo_kara_id
,
dest
)
.await
{
log
::
error!
(
target
:
"REPO"
,
"failed to download file `{}` for kara {repo_kara_id}: {err}"
,
dest
.to_string_lossy
());
return
;
return
;
}
}
make_kara_available!
(
db
,
remote_id
,
true
);
log
::
info!
(
log
::
info!
(
"downloaded kara {repo_kara_id} from {name} at location {}"
,
"downloaded kara {repo_kara_id} from {} at location {}"
,
name
.as_ref
(),
dest
.to_string_lossy
()
dest
.to_string_lossy
()
);
);
}
}
...
...
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