@@ -5,7 +5,7 @@ mod tests {
55
66 use crate :: fs:: FileSystem ;
77 use crate :: runtime:: types:: Fd ;
8- use crate :: storage:: types:: Node ;
8+ use crate :: storage:: types:: { MountedFileSizePolicy , Node } ;
99
1010 use ic_stable_structures:: memory_manager:: { MemoryId , MemoryManager } ;
1111 use ic_stable_structures:: { Memory , VectorMemory } ;
@@ -815,8 +815,12 @@ mod tests {
815815
816816 let root_fd = fs. root_fd ( ) ;
817817
818- fs. mount_memory_file ( "test.txt" , Box :: new ( memory. clone ( ) ) )
819- . unwrap ( ) ;
818+ fs. mount_memory_file (
819+ "test.txt" ,
820+ Box :: new ( memory. clone ( ) ) ,
821+ MountedFileSizePolicy :: PreviousOrZero ,
822+ )
823+ . unwrap ( ) ;
820824
821825 let content = "ABCDEFG123" ;
822826
@@ -836,8 +840,12 @@ mod tests {
836840
837841 let storage = StableStorage :: new_with_memory_manager ( & memory_manager, 200 ..210 ) ;
838842 let mut fs = FileSystem :: new ( Box :: new ( storage) ) . unwrap ( ) ;
839- fs. mount_memory_file ( "test.txt" , Box :: new ( memory. clone ( ) ) )
840- . unwrap ( ) ;
843+ fs. mount_memory_file (
844+ "test.txt" ,
845+ Box :: new ( memory. clone ( ) ) ,
846+ MountedFileSizePolicy :: PreviousOrZero ,
847+ )
848+ . unwrap ( ) ;
841849
842850 let root_fd = fs. root_fd ( ) ;
843851 let content = "ABCDEFG123" ;
@@ -846,8 +854,12 @@ mod tests {
846854 // imitate canister upgrade (we keep the memory manager but recreate the file system with the same virtual memories)
847855 let storage = StableStorage :: new_with_memory_manager ( & memory_manager, 200 ..210 ) ;
848856 let mut fs = FileSystem :: new ( Box :: new ( storage) ) . unwrap ( ) ;
849- fs. mount_memory_file ( "test.txt" , Box :: new ( memory. clone ( ) ) )
850- . unwrap ( ) ;
857+ fs. mount_memory_file (
858+ "test.txt" ,
859+ Box :: new ( memory. clone ( ) ) ,
860+ MountedFileSizePolicy :: PreviousOrZero ,
861+ )
862+ . unwrap ( ) ;
851863 let root_fd = fs. root_fd ( ) ;
852864
853865 let content = read_text_file ( & mut fs, root_fd, "test.txt" , 0 , 100 ) ;
@@ -863,8 +875,12 @@ mod tests {
863875
864876 let root_fd = fs. root_fd ( ) ;
865877
866- fs. mount_memory_file ( "test.txt" , Box :: new ( memory. clone ( ) ) )
867- . unwrap ( ) ;
878+ fs. mount_memory_file (
879+ "test.txt" ,
880+ Box :: new ( memory. clone ( ) ) ,
881+ MountedFileSizePolicy :: PreviousOrZero ,
882+ )
883+ . unwrap ( ) ;
868884
869885 let res = fs. remove_file ( root_fd, "test.txt" ) ;
870886
@@ -887,8 +903,12 @@ mod tests {
887903
888904 let file_name = "test.txt" ;
889905
890- fs. mount_memory_file ( file_name, Box :: new ( memory1. clone ( ) ) )
891- . unwrap ( ) ;
906+ fs. mount_memory_file (
907+ file_name,
908+ Box :: new ( memory1. clone ( ) ) ,
909+ MountedFileSizePolicy :: PreviousOrZero ,
910+ )
911+ . unwrap ( ) ;
892912
893913 let content = "ABCDEFG123" ;
894914 let len = content. len ( ) ;
@@ -921,8 +941,12 @@ mod tests {
921941 fs. unmount_memory_file ( file_name) . unwrap ( ) ;
922942
923943 // init new memory into a file
924- fs. mount_memory_file ( file_name, Box :: new ( memory2. clone ( ) ) )
925- . unwrap ( ) ;
944+ fs. mount_memory_file (
945+ file_name,
946+ Box :: new ( memory2. clone ( ) ) ,
947+ MountedFileSizePolicy :: PreviousOrZero ,
948+ )
949+ . unwrap ( ) ;
926950
927951 fs. init_memory_file ( file_name) . unwrap ( ) ;
928952
@@ -947,8 +971,12 @@ mod tests {
947971 let hello_message = "Hello host" . to_string ( ) ;
948972 let hello_message2 = "1234Hello from regular file" . to_string ( ) ;
949973
950- fs. mount_memory_file ( file_name, Box :: new ( memory. clone ( ) ) )
951- . unwrap ( ) ;
974+ fs. mount_memory_file (
975+ file_name,
976+ Box :: new ( memory. clone ( ) ) ,
977+ MountedFileSizePolicy :: PreviousOrZero ,
978+ )
979+ . unwrap ( ) ;
952980
953981 // write something into a host memory file
954982 write_text_file ( & mut fs, dir_fd, file_name, & hello_message, 1 ) . unwrap ( ) ;
@@ -966,8 +994,12 @@ mod tests {
966994 assert_eq ! ( str , "" . to_string( ) ) ;
967995
968996 // mount again, the old content should recover
969- fs. mount_memory_file ( file_name, Box :: new ( memory. clone ( ) ) )
970- . unwrap ( ) ;
997+ fs. mount_memory_file (
998+ file_name,
999+ Box :: new ( memory. clone ( ) ) ,
1000+ MountedFileSizePolicy :: PreviousOrZero ,
1001+ )
1002+ . unwrap ( ) ;
9711003 let str = read_text_file ( & mut fs, dir_fd, file_name, 0 , 1000 ) ;
9721004 assert_eq ! ( str , hello_message) ;
9731005
@@ -985,8 +1017,12 @@ mod tests {
9851017 assert_eq ! ( str , hello_message2) ;
9861018
9871019 // after mounting, we still have the old content
988- fs. mount_memory_file ( file_name, Box :: new ( memory. clone ( ) ) )
989- . unwrap ( ) ;
1020+ fs. mount_memory_file (
1021+ file_name,
1022+ Box :: new ( memory. clone ( ) ) ,
1023+ MountedFileSizePolicy :: PreviousOrZero ,
1024+ )
1025+ . unwrap ( ) ;
9901026 let str = read_text_file ( & mut fs, dir_fd, file_name, 0 , 1000 ) ;
9911027 assert_eq ! ( str , hello_message) ;
9921028
0 commit comments