Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/datasets/utils/_filelock.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"""Utilities to handle file locking in `datasets`."""

import os
from pathlib import Path

from filelock import FileLock as FileLock_
from filelock import UnixFileLock
Expand All @@ -32,13 +33,13 @@ class FileLock(FileLock_):
MAX_FILENAME_LENGTH = 255

def __init__(self, lock_file, *args, **kwargs):
lock_file = self.hash_filename_if_too_long(lock_file)
# instaed of usimg umask, create a lock file to accomodate ACL
Path(lock_file).touch()
# The "mode" argument is required if we want to use the current umask in filelock >= 3.10
# In previous previous it was already using the current umask.
if "mode" not in kwargs and version.parse(_filelock_version) >= version.parse("3.10.0"):
umask = os.umask(0o666)
os.umask(umask)
kwargs["mode"] = 0o666 & ~umask
lock_file = self.hash_filename_if_too_long(lock_file)
kwargs["mode"] = os.stat(lock_file).st_mode
super().__init__(lock_file, *args, **kwargs)

@classmethod
Expand Down