@@ -148,7 +148,9 @@ export async function prepareScriptByCode(
148148 try {
149149 nextTime ( metadata . crontab [ 0 ] ) ;
150150 } catch ( e ) {
151- throw new Error ( i18n_t ( "error_cron_invalid" , { expr : metadata . crontab [ 0 ] } ) ) ;
151+ throw new Error (
152+ i18n_t ( "error_cron_invalid" , { expr : metadata . crontab [ 0 ] } )
153+ ) ;
152154 }
153155 } else if ( metadata . background !== undefined ) {
154156 type = SCRIPT_TYPE_BACKGROUND ;
@@ -198,19 +200,29 @@ export async function prepareScriptByCode(
198200 if ( ! old && ( ! uuid || override ) ) {
199201 old = await dao . findByNameAndNamespace ( script . name , script . namespace ) ;
200202 }
201- const hasGrantConflict = ( metadata : SCMetadata | undefined | null ) =>
202- metadata ?. grant ?. includes ( "none" ) && metadata ?. grant ?. some ( ( s : string ) => s . startsWith ( "GM" ) ) ;
203- const hasDuplicatedMetaline = ( metadata : SCMetadata | undefined | null ) => {
204- if ( metadata ) {
205- for ( const list of Object . values ( metadata ) ) {
203+ const hasGrantConflict = ( meta : SCMetadata | undefined | null ) =>
204+ meta ?. grant ?. includes ( "none" ) &&
205+ meta ?. grant ?. some ( ( s : string ) => s . startsWith ( "GM" ) ) ;
206+ const hasDuplicatedMetaline = ( meta : SCMetadata | undefined | null ) => {
207+ if ( meta ) {
208+ for ( const list of Object . values ( meta ) ) {
206209 if ( list && new Set ( list ) . size !== list . length ) return true ;
207210 }
208211 }
212+ return false ;
209213 } ;
210- if ( options ?. byEditor && hasGrantConflict ( script . metadata ) && ( ! old || ! hasGrantConflict ( old . metadata ) ) ) {
214+ if (
215+ options ?. byEditor &&
216+ hasGrantConflict ( script . metadata ) &&
217+ ( ! old || ! hasGrantConflict ( old . metadata ) )
218+ ) {
211219 throw new Error ( i18n_t ( "error_grant_conflict" ) ) ;
212220 }
213- if ( options ?. byEditor && hasDuplicatedMetaline ( script . metadata ) && ( ! old || ! hasDuplicatedMetaline ( old . metadata ) ) ) {
221+ if (
222+ options ?. byEditor &&
223+ hasDuplicatedMetaline ( script . metadata ) &&
224+ ( ! old || ! hasDuplicatedMetaline ( old . metadata ) )
225+ ) {
214226 throw new Error ( i18n_t ( "error_metadata_line_duplicated" ) ) ;
215227 }
216228 if ( old ) {
0 commit comments