mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af3a5b9150 |
2 changed files with 5 additions and 4 deletions
|
|
@ -598,14 +598,14 @@ def link_or_copy(src, dst):
|
|||
# https://github.com/simonw/datasette/issues/141
|
||||
try:
|
||||
os.link(src, dst)
|
||||
except OSError:
|
||||
except shutil.Error:
|
||||
shutil.copyfile(src, dst)
|
||||
|
||||
|
||||
def link_or_copy_directory(src, dst):
|
||||
try:
|
||||
shutil.copytree(src, dst, copy_function=os.link)
|
||||
except OSError:
|
||||
except shutil.Error:
|
||||
shutil.copytree(src, dst)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import json
|
|||
import os
|
||||
import pathlib
|
||||
import pytest
|
||||
import shutil
|
||||
import sqlite3
|
||||
import tempfile
|
||||
from unittest.mock import patch
|
||||
|
|
@ -253,8 +254,8 @@ def test_temporary_docker_directory_uses_hard_link():
|
|||
|
||||
@patch("os.link")
|
||||
def test_temporary_docker_directory_uses_copy_if_hard_link_fails(mock_link):
|
||||
# Copy instead if os.link raises OSError (normally due to different device)
|
||||
mock_link.side_effect = OSError
|
||||
# Copy instead if shutil.Error (normally due to different device)
|
||||
mock_link.side_effect = shutil.Error
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
os.chdir(td)
|
||||
open("hello", "w").write("world")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue