@@ -74,12 +74,24 @@ const harness = Effect.gen(function* () {
7474 ) ;
7575 } ) ,
7676 ) ;
77- const store = yield * SpeechModelStore . SpeechModelStore . pipe (
77+ const openStore = SpeechModelStore . SpeechModelStore . pipe (
7878 Effect . provide (
7979 SpeechModelStore . layer . pipe ( Layer . provide ( Layer . succeed ( HttpClient . HttpClient , client ) ) ) ,
8080 ) ,
8181 ) ;
82- return { model, directory, stale, fs, requests, bodies, transportFailure, bodyStarted, store } ;
82+ const store = yield * openStore ;
83+ return {
84+ model,
85+ directory,
86+ stale,
87+ fs,
88+ requests,
89+ bodies,
90+ transportFailure,
91+ bodyStarted,
92+ store,
93+ openStore,
94+ } ;
8395} ) ;
8496
8597const dependencies = ServerConfig . layerTest ( "/tmp" , { prefix : "speech-model-store-" } ) . pipe (
@@ -137,7 +149,7 @@ it.effect("rejects a same-size download whose SHA-256 differs from the catalog",
137149 } ) . pipe ( Effect . provide ( dependencies ) ) ,
138150) ;
139151
140- it . effect ( "cancelling a download removes the partial file and keeps the existing model " , ( ) =>
152+ it . effect ( "cleans only download partials on cancellation or restart " , ( ) =>
141153 Effect . gen ( function * ( ) {
142154 const h = yield * harness ;
143155 h . bodies . current = ( ) => Stream . concat ( Stream . succeed ( bytes . subarray ( 0 , SPLIT ) ) , Stream . never ) ;
@@ -146,5 +158,13 @@ it.effect("cancelling a download removes the partial file and keeps the existing
146158 yield * Fiber . interrupt ( fiber ) ;
147159 expect ( yield * h . fs . readDirectory ( h . directory ) ) . toEqual ( [ "model.gguf" ] ) ;
148160 expect ( [ ...( yield * h . fs . readFile ( h . stale ) ) ] ) . toEqual ( [ ...new Uint8Array ( bytes . length ) ] ) ;
161+ const orphan = `${ h . stale } .f660de6c-e172-4146-8ffe-d3c32eb48cd4.part` ;
162+ yield * h . fs . writeFile ( orphan , bytes . subarray ( 0 , SPLIT ) ) ;
163+ yield * h . fs . writeFileString ( `${ h . stale } .notes.part` , "not a download" ) ;
164+ yield * h . openStore ;
165+ expect ( ( yield * h . fs . readDirectory ( h . directory ) ) . sort ( ) ) . toEqual ( [
166+ "model.gguf" ,
167+ "model.gguf.notes.part" ,
168+ ] ) ;
149169 } ) . pipe ( Effect . provide ( dependencies ) ) ,
150170) ;
0 commit comments