fsspec / fsspec/gcsfs

touch(truncate=True) is a bad default

Open
#364 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
398
Forks
181
Avg merge
2d 10h
Merged PRs (30d)
36

Description

What happened:

I wanted to update the timestamp on 2000 objects, comprising of 5 TB of data on Google Cloud. So I ran

for obj in obj_list:
    fs.touch(obj)

What you expected to happen:

Consistent with my experience with the unix touch command, I assumed the default behavior would be to just update the modification time. Instead, I lost 5 TB of valuable data. This is my fault, for not reading the docstring

Signature: fs.touch(path, truncate=True, **kwargs)
Docstring:
Create empty file, or update timestamp

Parameters
----------
path: str
    file location
truncate: bool
    If True, always set file size to 0; if False, update timestamp and
    leave file unchanged, if backend allows this

However, I would argue that this is a very bad default value for truncate. Why deviate from the standard unix behavior? I can't be the first user to make this mistake...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue identifies fs.touch(path, truncate=True, **kwargs) and its docstring as the relevant entry point; start there and inspect how the default is documented and exercised. Decide whether the default should match Unix touch semantics, then update the behavior and documentation so the default preserves existing data while an explicit truncation option remains available.

Written by the indexing model from the issue text.

Assessment

Tech stack
google-cloud, python
Domain
cloud
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.