File tree Expand file tree Collapse file tree 3 files changed +28
-3
lines changed
Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,24 @@ namespace SQLite.CodeFirst.Utility
55{
66 internal class InMemoryAwareFile
77 {
8+ public static FileAttributes ? GetFileAttributes ( string path )
9+ {
10+ if ( IsInMemoryPath ( path ) )
11+ {
12+ return null ;
13+ }
14+ return File . GetAttributes ( path ) ;
15+ }
16+
17+ public static void SetFileAttributes ( string path , FileAttributes ? fileAttributes )
18+ {
19+ if ( IsInMemoryPath ( path ) || fileAttributes == null )
20+ {
21+ return ;
22+ }
23+ File . SetAttributes ( path , fileAttributes . Value ) ;
24+ }
25+
826 public static bool Exists ( string path )
927 {
1028 if ( IsInMemoryPath ( path ) )
Original file line number Diff line number Diff line change @@ -34,10 +34,15 @@ public override void InitializeDatabase(TContext context)
3434 bool exists = InMemoryAwareFile . Exists ( databseFilePath ) ;
3535 if ( exists )
3636 {
37+ FileAttributes ? attributes = InMemoryAwareFile . GetFileAttributes ( databseFilePath ) ;
3738 InMemoryAwareFile . Delete ( databseFilePath ) ;
39+ base . InitializeDatabase ( context ) ;
40+ InMemoryAwareFile . SetFileAttributes ( databseFilePath , attributes ) ;
41+ }
42+ else
43+ {
44+ base . InitializeDatabase ( context ) ;
3845 }
39-
40- base . InitializeDatabase ( context ) ;
4146 }
4247 }
4348}
Original file line number Diff line number Diff line change @@ -70,16 +70,18 @@ public override void InitializeDatabase(TContext context)
7070 {
7171 string databseFilePath = GetDatabasePathFromContext ( context ) ;
7272
73- bool dbExists = File . Exists ( databseFilePath ) ;
73+ bool dbExists = InMemoryAwareFile . Exists ( databseFilePath ) ;
7474 if ( dbExists )
7575 {
7676 if ( IsSameModel ( context ) )
7777 {
7878 return ;
7979 }
8080
81+ FileAttributes ? attributes = InMemoryAwareFile . GetFileAttributes ( databseFilePath ) ;
8182 DeleteDatabase ( context , databseFilePath ) ;
8283 base . InitializeDatabase ( context ) ;
84+ InMemoryAwareFile . SetFileAttributes ( databseFilePath , attributes ) ;
8385 SaveHistory ( context ) ;
8486 }
8587 else
You can’t perform that action at this time.
0 commit comments