@@ -150,6 +150,7 @@ def test_empty_unknown_pdf_and_missing_files(tmp_path):
150150
151151
152152def test_chained_fsspec_file_and_storage_options (tmp_path , monkeypatch ):
153+ pytest .importorskip ("fsspec" )
153154 import zipfile
154155
155156 from blosc2 .b2view import ordinary_file
@@ -177,7 +178,7 @@ def filesystem(source, options):
177178 assert all (options == {"custom" : "value" } for options in seen )
178179
179180
180- def test_publication_race_and_late_cancellation (tmp_path , monkeypatch ):
181+ def test_late_cancellation (tmp_path ):
181182 source = tmp_path / "source.txt"
182183 source .write_bytes (b"hello" )
183184 file = OrdinaryFile (source )
@@ -192,6 +193,14 @@ def progress(done, total):
192193 file .download (destination , progress = progress , cancel = lambda : cancelled )
193194 assert not destination .exists ()
194195 assert not list (tmp_path .glob (".b2view-download-*" ))
196+
197+
198+ @pytest .mark .skipif (blosc2 .IS_WASM , reason = "emscripten has no hard links" )
199+ def test_publication_race (tmp_path , monkeypatch ):
200+ source = tmp_path / "source.txt"
201+ source .write_bytes (b"hello" )
202+ file = OrdinaryFile (source )
203+ destination = tmp_path / "destination.txt"
195204 original = __import__ ("os" ).link
196205
197206 def race (temporary , target ):
@@ -205,6 +214,30 @@ def race(temporary, target):
205214 assert not list (tmp_path .glob (".b2view-download-*" ))
206215
207216
217+ @pytest .mark .parametrize ("competing_writer" , [False , True ])
218+ def test_wasm_download_publication (tmp_path , monkeypatch , competing_writer ):
219+ monkeypatch .setattr (blosc2 , "IS_WASM" , True )
220+ source = tmp_path / "source.txt"
221+ source .write_bytes (b"hello" )
222+ destination = tmp_path / "destination.txt"
223+ file = OrdinaryFile (source )
224+
225+ def progress (done , total ):
226+ if competing_writer :
227+ destination .write_bytes (b"existing" )
228+
229+ if competing_writer :
230+ with pytest .raises (FileExistsError ):
231+ file .download (destination , progress = progress )
232+ assert destination .read_bytes () == b"existing"
233+ else :
234+ file .download (destination , progress = progress )
235+ assert destination .read_bytes () == b"hello"
236+ with pytest .raises (FileExistsError ):
237+ file .download (destination )
238+ assert not list (tmp_path .glob (".b2view-download-*" ))
239+
240+
208241@pytest .mark .parametrize (
209242 "source" ,
210243 [
0 commit comments