@@ -31,7 +31,6 @@ use common::{
31
31
value:: {
32
32
ConvexValue ,
33
33
ResolvedDocumentId ,
34
- VALUE_TOO_LARGE_SHORT_MSG ,
35
34
} ,
36
35
} ;
37
36
use database:: {
@@ -42,14 +41,8 @@ use database::{
42
41
SystemMetadataModel ,
43
42
Transaction ,
44
43
} ;
45
- use errors:: {
46
- ErrorMetadata ,
47
- ErrorMetadataAnyhowExt ,
48
- } ;
49
- use metrics:: {
50
- get_module_metadata_timer,
51
- get_module_version_timer,
52
- } ;
44
+ use errors:: ErrorMetadata ;
45
+ use metrics:: get_module_metadata_timer;
53
46
use sync_types:: CanonicalizedModulePath ;
54
47
use value:: {
55
48
sha256:: {
@@ -309,39 +302,6 @@ impl<'a, RT: Runtime> ModuleModel<'a, RT> {
309
302
Ok ( modules)
310
303
}
311
304
312
- pub async fn get_version (
313
- & mut self ,
314
- module_id : ResolvedDocumentId ,
315
- version : Option < ModuleVersion > ,
316
- ) -> anyhow:: Result < Option < ParsedDocument < ModuleVersionMetadata > > > {
317
- let timer = get_module_version_timer ( ) ;
318
- let module_id_value: ConvexValue = module_id. into ( ) ;
319
- let index_range = IndexRange {
320
- index_name : MODULE_VERSION_INDEX . clone ( ) ,
321
- range : vec ! [ IndexRangeExpression :: Eq (
322
- MODULE_ID_FIELD . clone( ) ,
323
- module_id_value. into( ) ,
324
- ) ] ,
325
- order : Order :: Asc ,
326
- } ;
327
- let module_query = Query :: index_range ( index_range) ;
328
- let namespace = self
329
- . tx
330
- . table_mapping ( )
331
- . tablet_namespace ( module_id. table ( ) . tablet_id ) ?;
332
- let mut query_stream = ResolvedQuery :: new ( self . tx , namespace, module_query) ?;
333
- let module_version: Option < ParsedDocument < ModuleVersionMetadata > > = query_stream
334
- . expect_at_most_one ( self . tx )
335
- . await ?
336
- . map ( TryFrom :: try_from)
337
- . transpose ( ) ?;
338
- if let Some ( module_version) = & module_version {
339
- anyhow:: ensure!( module_version. version == version) ;
340
- }
341
- timer. finish ( ) ;
342
- Ok ( module_version)
343
- }
344
-
345
305
pub async fn get_metadata_for_function (
346
306
& mut self ,
347
307
path : CanonicalizedComponentFunctionPath ,
@@ -392,13 +352,10 @@ impl<'a, RT: Runtime> ModuleModel<'a, RT> {
392
352
path. module_path. is_deps( ) || analyze_result. is_some( ) ,
393
353
"AnalyzedModule is required for non-dependency modules"
394
354
) ;
395
- let component = path. component ;
396
355
let sha256 = hash_module_source ( & source, source_map. as_ref ( ) ) ;
397
- let ( module_id, version) = self
398
- . put_module_metadata ( path, source_package_id, analyze_result, environment, sha256)
356
+ self . put_module_metadata ( path, source_package_id, analyze_result, environment, sha256)
399
357
. await ?;
400
- self . put_module_source_into_db ( module_id, version, source, source_map, component)
401
- . await
358
+ Ok ( ( ) )
402
359
}
403
360
404
361
async fn put_module_metadata (
@@ -413,12 +370,6 @@ impl<'a, RT: Runtime> ModuleModel<'a, RT> {
413
370
Some ( module_metadata) => {
414
371
let previous_version = module_metadata. latest_version ;
415
372
416
- // Delete the old module version since it has no more references.
417
- let previous_version_id = self
418
- . get_version ( module_metadata. id ( ) , previous_version)
419
- . await ?
420
- . map ( |version| version. id ( ) ) ;
421
-
422
373
let latest_version = previous_version. map ( |v| v + 1 ) ;
423
374
let new_metadata = ModuleMetadata {
424
375
path : path. module_path ,
@@ -432,12 +383,6 @@ impl<'a, RT: Runtime> ModuleModel<'a, RT> {
432
383
. replace ( module_metadata. id ( ) , new_metadata. try_into ( ) ?)
433
384
. await ?;
434
385
435
- if let Some ( previous_version_id) = previous_version_id {
436
- SystemMetadataModel :: new ( self . tx , path. component . into ( ) )
437
- . delete ( previous_version_id)
438
- . await ?;
439
- }
440
-
441
386
( module_metadata. id ( ) , latest_version)
442
387
} ,
443
388
None => {
@@ -460,41 +405,6 @@ impl<'a, RT: Runtime> ModuleModel<'a, RT> {
460
405
Ok ( ( module_id, version) )
461
406
}
462
407
463
- async fn put_module_source_into_db (
464
- & mut self ,
465
- module_id : ResolvedDocumentId ,
466
- version : Option < ModuleVersion > ,
467
- source : ModuleSource ,
468
- source_map : Option < SourceMap > ,
469
- component : ComponentId ,
470
- ) -> anyhow:: Result < ( ) > {
471
- let new_version = ModuleVersionMetadata {
472
- module_id : module_id. into ( ) ,
473
- source,
474
- source_map,
475
- version,
476
- } . try_into ( )
477
- . map_err ( |e : anyhow:: Error | e. map_error_metadata ( |em| {
478
- if em. short_msg == VALUE_TOO_LARGE_SHORT_MSG {
479
- // Remap the ValueTooLargeError message to something more specific
480
- // to the modules use case.
481
- let message = format ! (
482
- "The functions, source maps, and their dependencies in \" convex/\" are too large. See our docs (https://docs.convex.dev/using/writing-convex-functions#using-libraries) for more details. You can also run `npx convex deploy -v` to print out each source file's bundled size.\n {}" , em. msg
483
- ) ;
484
- ErrorMetadata :: bad_request (
485
- "ModulesTooLarge" ,
486
- message,
487
- )
488
- } else {
489
- em
490
- }
491
- } ) ) ?;
492
- SystemMetadataModel :: new ( self . tx , component. into ( ) )
493
- . insert ( & MODULE_VERSIONS_TABLE , new_version)
494
- . await ?;
495
- Ok ( ( ) )
496
- }
497
-
498
408
/// Delete a module, making it inaccessible for subsequent transactions.
499
409
pub async fn delete ( & mut self , path : CanonicalizedComponentModulePath ) -> anyhow:: Result < ( ) > {
500
410
if !( self . tx . identity ( ) . is_admin ( ) || self . tx . identity ( ) . is_system ( ) ) {
@@ -506,16 +416,6 @@ impl<'a, RT: Runtime> ModuleModel<'a, RT> {
506
416
SystemMetadataModel :: new ( self . tx , namespace)
507
417
. delete ( module_id)
508
418
. await ?;
509
-
510
- // Delete the module version since it has no more references.
511
- if let Some ( module_version) = self
512
- . get_version ( module_id, module_metadata. latest_version )
513
- . await ?
514
- {
515
- SystemMetadataModel :: new ( self . tx , namespace)
516
- . delete ( module_version. id ( ) )
517
- . await ?;
518
- }
519
419
}
520
420
Ok ( ( ) )
521
421
}
0 commit comments