@@ -68,8 +68,6 @@ public string Name
68
68
69
69
private readonly IFileSystem _fileSystem ;
70
70
private readonly IEnvironmentInfo _environmentInfo ;
71
- private readonly ITimerFactory _timerFactory ;
72
- private ITimer _shrinkMemoryTimer ;
73
71
private IServerApplicationHost _appHost ;
74
72
75
73
/// <summary>
@@ -92,7 +90,6 @@ public SqliteItemRepository(IServerConfigurationManager config, IServerApplicati
92
90
_jsonSerializer = jsonSerializer ;
93
91
_fileSystem = fileSystem ;
94
92
_environmentInfo = environmentInfo ;
95
- _timerFactory = timerFactory ;
96
93
_typeMapper = new TypeMapper ( assemblyInfo ) ;
97
94
98
95
DbFilePath = Path . Combine ( _config . ApplicationPaths . DataPath , "library.db" ) ;
@@ -116,17 +113,6 @@ protected override bool EnableTempStoreMemory
116
113
}
117
114
}
118
115
119
- protected override void CloseConnection ( )
120
- {
121
- if ( _shrinkMemoryTimer != null )
122
- {
123
- _shrinkMemoryTimer . Dispose ( ) ;
124
- _shrinkMemoryTimer = null ;
125
- }
126
-
127
- base . CloseConnection ( ) ;
128
- }
129
-
130
116
/// <summary>
131
117
/// Opens the connection to the database
132
118
/// </summary>
@@ -356,31 +342,6 @@ var createMediaStreamsTableCommand
356
342
}
357
343
358
344
userDataRepo . Initialize ( WriteLock , _connection ) ;
359
-
360
- _shrinkMemoryTimer = _timerFactory . Create ( OnShrinkMemoryTimerCallback , null , TimeSpan . FromMinutes ( 1 ) , TimeSpan . FromHours ( 6 ) ) ;
361
- }
362
-
363
- private void OnShrinkMemoryTimerCallback ( object state )
364
- {
365
- try
366
- {
367
- using ( WriteLock . Write ( ) )
368
- {
369
- using ( var connection = CreateConnection ( ) )
370
- {
371
- connection . RunQueries ( new string [ ]
372
- {
373
- "pragma shrink_memory"
374
- } ) ;
375
- }
376
- }
377
-
378
- GC . Collect ( ) ;
379
- }
380
- catch ( Exception ex )
381
- {
382
- Logger . ErrorException ( "Error running shrink memory" , ex ) ;
383
- }
384
345
}
385
346
386
347
private readonly string [ ] _retriveItemColumns =
@@ -3468,92 +3429,94 @@ private List<string> GetWhereClauses(InternalItemsQuery query, IStatement statem
3468
3429
var tags = query . Tags . ToList ( ) ;
3469
3430
var excludeTags = query . ExcludeTags . ToList ( ) ;
3470
3431
3471
- if ( ! ( query . IsMovie ?? true ) || ! ( query . IsSeries ?? true ) )
3432
+ //if (!(query.IsMovie ?? true) || !(query.IsSeries ?? true))
3433
+ //{
3434
+ // if (query.IsMovie.HasValue)
3435
+ // {
3436
+ // var alternateTypes = new List<string>();
3437
+ // if (query.IncludeItemTypes.Length == 0 || query.IncludeItemTypes.Contains(typeof(Movie).Name))
3438
+ // {
3439
+ // alternateTypes.Add(typeof(Movie).FullName);
3440
+ // }
3441
+ // if (query.IncludeItemTypes.Length == 0 || query.IncludeItemTypes.Contains(typeof(Trailer).Name))
3442
+ // {
3443
+ // alternateTypes.Add(typeof(Trailer).FullName);
3444
+ // }
3445
+
3446
+ // if (alternateTypes.Count == 0)
3447
+ // {
3448
+ // whereClauses.Add("IsMovie=@IsMovie");
3449
+ // if (statement != null)
3450
+ // {
3451
+ // statement.TryBind("@IsMovie", query.IsMovie);
3452
+ // }
3453
+ // }
3454
+ // else
3455
+ // {
3456
+ // whereClauses.Add("(IsMovie is null OR IsMovie=@IsMovie)");
3457
+ // if (statement != null)
3458
+ // {
3459
+ // statement.TryBind("@IsMovie", query.IsMovie);
3460
+ // }
3461
+ // }
3462
+ // }
3463
+ //}
3464
+ //else
3465
+ //{
3466
+
3467
+ //}
3468
+
3469
+ if ( query . IsMovie ?? false )
3472
3470
{
3473
- if ( query . IsMovie . HasValue )
3474
- {
3475
- var alternateTypes = new List < string > ( ) ;
3476
- if ( query . IncludeItemTypes . Length == 0 || query . IncludeItemTypes . Contains ( typeof ( Movie ) . Name ) )
3477
- {
3478
- alternateTypes . Add ( typeof ( Movie ) . FullName ) ;
3479
- }
3480
- if ( query . IncludeItemTypes . Length == 0 || query . IncludeItemTypes . Contains ( typeof ( Trailer ) . Name ) )
3481
- {
3482
- alternateTypes . Add ( typeof ( Trailer ) . FullName ) ;
3483
- }
3471
+ var programAttribtues = new List < string > ( ) ;
3484
3472
3485
- if ( alternateTypes . Count == 0 )
3486
- {
3487
- whereClauses . Add ( "IsMovie=@IsMovie" ) ;
3488
- if ( statement != null )
3489
- {
3490
- statement . TryBind ( "@IsMovie" , query . IsMovie ) ;
3491
- }
3492
- }
3493
- else
3494
- {
3495
- whereClauses . Add ( "(IsMovie is null OR IsMovie=@IsMovie)" ) ;
3496
- if ( statement != null )
3497
- {
3498
- statement . TryBind ( "@IsMovie" , query . IsMovie ) ;
3499
- }
3500
- }
3501
- }
3502
- if ( query . IsSeries . HasValue )
3473
+ var alternateTypes = new List < string > ( ) ;
3474
+ if ( query . IncludeItemTypes . Length == 0 || query . IncludeItemTypes . Contains ( typeof ( Movie ) . Name ) )
3503
3475
{
3504
- whereClauses . Add ( "IsSeries=@IsSeries" ) ;
3505
- if ( statement != null )
3506
- {
3507
- statement . TryBind ( "@IsSeries" , query . IsSeries ) ;
3508
- }
3476
+ alternateTypes . Add ( typeof ( Movie ) . FullName ) ;
3509
3477
}
3510
- }
3511
- else
3512
- {
3513
- var programAttribtues = new List < string > ( ) ;
3514
- if ( query . IsMovie ?? false )
3478
+ if ( query . IncludeItemTypes . Length == 0 || query . IncludeItemTypes . Contains ( typeof ( Trailer ) . Name ) )
3515
3479
{
3516
- var alternateTypes = new List < string > ( ) ;
3517
- if ( query . IncludeItemTypes . Length == 0 || query . IncludeItemTypes . Contains ( typeof ( Movie ) . Name ) )
3518
- {
3519
- alternateTypes . Add ( typeof ( Movie ) . FullName ) ;
3520
- }
3521
- if ( query . IncludeItemTypes . Length == 0 || query . IncludeItemTypes . Contains ( typeof ( Trailer ) . Name ) )
3522
- {
3523
- alternateTypes . Add ( typeof ( Trailer ) . FullName ) ;
3524
- }
3480
+ alternateTypes . Add ( typeof ( Trailer ) . FullName ) ;
3481
+ }
3525
3482
3526
- if ( alternateTypes . Count == 0 )
3527
- {
3528
- programAttribtues . Add ( "IsMovie=@IsMovie" ) ;
3529
- }
3530
- else
3531
- {
3532
- programAttribtues . Add ( "(IsMovie is null OR IsMovie=@IsMovie)" ) ;
3533
- }
3483
+ if ( alternateTypes . Count == 0 )
3484
+ {
3485
+ programAttribtues . Add ( "IsMovie=@IsMovie" ) ;
3486
+ }
3487
+ else
3488
+ {
3489
+ programAttribtues . Add ( "(IsMovie is null OR IsMovie=@IsMovie)" ) ;
3490
+ }
3534
3491
3535
- if ( statement != null )
3536
- {
3537
- statement . TryBind ( "@IsMovie" , true ) ;
3538
- }
3492
+ if ( statement != null )
3493
+ {
3494
+ statement . TryBind ( "@IsMovie" , true ) ;
3539
3495
}
3540
- if ( query . IsSeries ?? false )
3496
+
3497
+ whereClauses . Add ( "(" + string . Join ( " OR " , programAttribtues . ToArray ( programAttribtues . Count ) ) + ")" ) ;
3498
+ }
3499
+ else if ( query . IsMovie . HasValue )
3500
+ {
3501
+ whereClauses . Add ( "IsMovie=@IsMovie" ) ;
3502
+ if ( statement != null )
3541
3503
{
3542
- programAttribtues . Add ( "IsSeries=@IsSeries" ) ;
3543
- if ( statement != null )
3544
- {
3545
- statement . TryBind ( "@IsSeries" , query . IsSeries ) ;
3546
- }
3504
+ statement . TryBind ( "@IsMovie" , query . IsMovie ) ;
3547
3505
}
3548
- if ( programAttribtues . Count > 0 )
3506
+ }
3507
+
3508
+ if ( query . IsSeries . HasValue )
3509
+ {
3510
+ whereClauses . Add ( "IsSeries=@IsSeries" ) ;
3511
+ if ( statement != null )
3549
3512
{
3550
- whereClauses . Add ( "(" + string . Join ( " OR " , programAttribtues . ToArray ( programAttribtues . Count ) ) + ")" ) ;
3513
+ statement . TryBind ( "@IsSeries" , query . IsSeries ) ;
3551
3514
}
3552
3515
}
3553
3516
3554
3517
if ( query . IsSports . HasValue )
3555
3518
{
3556
- if ( query . IsSports . HasValue )
3519
+ if ( query . IsSports . Value )
3557
3520
{
3558
3521
tags . Add ( "Sports" ) ;
3559
3522
}
@@ -3565,7 +3528,7 @@ private List<string> GetWhereClauses(InternalItemsQuery query, IStatement statem
3565
3528
3566
3529
if ( query . IsNews . HasValue )
3567
3530
{
3568
- if ( query . IsNews . HasValue )
3531
+ if ( query . IsNews . Value )
3569
3532
{
3570
3533
tags . Add ( "News" ) ;
3571
3534
}
@@ -3577,7 +3540,7 @@ private List<string> GetWhereClauses(InternalItemsQuery query, IStatement statem
3577
3540
3578
3541
if ( query . IsKids . HasValue )
3579
3542
{
3580
- if ( query . IsKids . HasValue )
3543
+ if ( query . IsKids . Value )
3581
3544
{
3582
3545
tags . Add ( "Kids" ) ;
3583
3546
}
@@ -3656,8 +3619,8 @@ private List<string> GetWhereClauses(InternalItemsQuery query, IStatement statem
3656
3619
3657
3620
if ( ! string . IsNullOrWhiteSpace ( query . Path ) )
3658
3621
{
3659
- // whereClauses.Add("(Path=@Path COLLATE NOCASE)");
3660
- whereClauses . Add ( "Path=@Path" ) ;
3622
+ whereClauses . Add ( "(Path=@Path COLLATE NOCASE)" ) ;
3623
+ // whereClauses.Add("Path=@Path");
3661
3624
if ( statement != null )
3662
3625
{
3663
3626
statement . TryBind ( "@Path" , GetPathToSave ( query . Path ) ) ;
0 commit comments