Skip to content

Releases

v1.0.0-rc.8

v1.0.0-rc.8 Pre-release
Pre-release

Choose a tag to compare

@ungerik ungerik released this 14 Nov 12:59
ce43e93

Eighth release candidate: gitfs, a read-only file system for a commit of
a remote git repository on GitHub, GitLab or any other git server. The
other modules are unchanged.

Added

  • gitfs, a new module: gitfs.New(ctx, repoURL, ref, opts) opens a
    branch, tag or commit of a repository URL as a read-only file system, and
    fs.File("git+https://github.com/owner/repo.git@v1.0.0/README.md")
    reads its files after fs.Register. It speaks the git smart HTTP
    protocol version 2 with the standard library only, without a git binary,
    go-git or a clone on disk.
  • Nothing is downloaded up front: New resolves the ref with two
    requests, directories load when a path below them is accessed and file
    content when it is read, with a cache of Options.CacheSize. On
    github.com, the GitHub REST API supplies the file sizes and a file is read
    from raw.githubusercontent.com: reading one file in the root directory
    of the latest version takes five requests, New included.
  • Authentication with an access token (Options.Token) or a username and
    password, also from the user info of the URL, which never appears in the
    prefix, IDs or error messages.
  • Limits for content from a hostile server: Options.MaxObjectSize per
    file, Options.MaxFetchSize per response including a fixed overhead per
    object, at most 2M files and directories, and paths of at most 4096
    bytes. Every object is verified against its ID and every packfile
    against its checksum.
  • Symbolic links, submodules and names that can't be file names of a
    checkout (.git, names with a backslash, names that are not valid UTF-8)
    are not exposed.
  • A tutorial step that prints the README of this repository through
    gitfs, and gitfs in the README, the connect-a-backend how-to and the
    support matrices.

v1.0.0-rc.7

v1.0.0-rc.7 Pre-release
Pre-release

Choose a tag to compare

@ungerik ungerik released this 06 Nov 20:33
032377c

Seventh release candidate: gofs, a command line tool for files on every
file system of go-fs, also between them. The library modules are unchanged.

Added

  • cmd/gofs, a command line tool for local files, HTTP, FTP, SFTP, SMB,
    WebDAV, S3, Azure Blob Storage and Dropbox: ls, stat, cat, put,
    cp, mv, rm, mkdir, touch, hash (Dropbox content hash, SHA-256
    or MD5) and cmp, also across file systems, like
    gofs cp -r s3://bucket/dir sftp://host/dir. The remote file systems
    connect on first use with credentials from environment variables and the
    setups of ssh, the AWS CLI and az login; gofs env lists the
    variables and which of them are set, never their values. Install it with
    go install github.com/ungerik/go-fs/cmd/gofs@latest or download it from
    the release.
  • put keeps an existing file when stdin fails or the command is
    interrupted: S3, Azure Blob Storage, Dropbox, WebDAV and FTP discard the
    incomplete upload, and on the local file system, SFTP and SMB the file is
    replaced by renaming a complete temporary file over it.
  • rm refuses a path that ends with . or .., also percent-encoded in a
    URI, before it removes anything.
  • The Azure credentials of the environment are only sent to the storage
    account host, the FTP and SMB passwords of the environment never to an
    anonymous FTP login or an SMB guest session, and errors never print the
    passwords of URIs.
  • Release archives of gofs for Linux, macOS and Windows on amd64 and
    arm64 with SHA-256 checksums, built by the new release-gofs workflow
    for every published release.

Changed

  • cmd/gofs requires the go-fs modules of its own release without
    replace directives, unlike the backend modules, so that go install
    works; gofs version prints both versions. The new ./gofs-require.sh
    sets them in the release PR before the tags exist, the CI and
    ./test-workspace.sh build cmd/gofs without the workspace through it,
    and tag-release.sh refuses a release whose cmd/gofs/go.sum doesn't
    match the modules.

v1.0.0-rc.6

v1.0.0-rc.6 Pre-release
Pre-release

Choose a tag to compare

@ungerik ungerik released this 03 Nov 16:09
64e9625

Sixth release candidate: the conformance suite now checks that copies and
moves never lose data when the destination is another name of the source,
and covers the optional path, hidden, ownership and watch interfaces, the
listing and write helpers of File and its io/fs view. The new checks
found a move through a linked directory under another case that deleted
the file; it is refused now.

Fixed

  • The copy-then-delete fallback of fs.Move no longer deletes a file that
    one path reaches through a link to a parent directory under another case
    of its name on a case-insensitive server, like a move of real/src.txt
    to LINK/SRC.TXT, or of link/src.txt to REAL/SRC.TXT, with link
    pointing to real. The fallback runs within a file system that is not
    local, has symbolic links and no native Move, also through
    a SubFileSystem of one, and through an OverlayFileSystem, also one
    with an sftpfs or smbfs layer; sftpfs and smbfs on their own move
    natively on the server. It compared the spellings of the paths before
    resolving their links, took the destination for another file, copied the
    file onto itself and removed it. It now refuses such a move with an error
    wrapping os.ErrInvalid.

Added

  • fstest.RunConformance checks that copies and moves never lose data when
    the destination names the source another way (Aliases): a link to the
    source or to a parent directory, another hard link, another case or Unicode
    normalization of the name, also through a linked directory, and the root
    of a SubFileSystem. The new Config.HardLink lets a file system with
    hard links run those checks; sftpfs and smbfs run them against their test
    servers.
  • fstest.RunConformance also checks URIFileSystem, VolumeNameFileSystem,
    AbsPathFileSystem (PathInterfaces), HiddenFileSystem (Hidden),
    UserFileSystem and GroupFileSystem (Ownership), WatchFileSystem
    (Watch), the listing helpers of File and its io/fs view File.StdFS
    with testing/fstest.TestFS (ListingHelpers), and the write helpers of
    File (WriteHelpers). A file system that doesn't pass a new check yet can
    skip it with Config.Skip; s3fs and azureblobfs skip
    ListingHelpers/StdFS for now: their listings and Stat report
    different modification times for some entries, and azureblobfs opens
    a path with a backslash like one with a slash.

v1.0.0-rc.5

v1.0.0-rc.5 Pre-release
Pre-release

Choose a tag to compare

@ungerik ungerik released this 02 Nov 14:51
be9aff4

Fifth release candidate: s3fs works with more S3-compatible services:
Cloudflare R2, Backblaze B2, Wasabi, DigitalOcean Spaces, Google Cloud
Storage and Hetzner Object Storage, see the client settings for each in the
s3fs README. A move between two Unicode normalizations of a file name, which
R2 stores as one object, is refused instead of deleting the file.

Changed

  • s3fs multipart uploads and ranged downloads use checksums only if the
    client is configured with WhenSupported, which config.LoadDefaultConfig
    sets. The transfer manager sent CRC32 checksums and validated downloads
    also for a client of s3.New without checksum options, which sends none,
    so on services without these checksums, like Backblaze B2 and Google Cloud
    Storage, uploads of MultipartUploadThreshold bytes or more failed while
    smaller ones worked. Downloads of a client whose response checksum
    validation is not set are no longer validated.
  • s3fs CopyFile downloads and uploads an object that the service refuses
    to copy with 501 Not Implemented or 413, like Cloudflare R2 and
    Backblaze B2 the conditions of UploadPartCopy for objects above 5 GiB,
    with the metadata of the source but without its tags. A download whose
    Content-Length or Content-Encoding differs from the object, like the
    decompressed data of a gzip object on Google Cloud Storage, is not uploaded,
    CopyFile returns an fs.ErrUnsupported error then. Touch returns an
    fs.ErrUnsupported error for such a service. On Google Cloud Storage
    endpoints, which have no UploadPartCopy, objects of every size are
    copied with CopyObject.

Fixed

  • s3fs ListDir, ListDirRecursive and RemoveAll return an error for
    a truncated listing page without a new continuation token. The SDK
    paginator ended such a listing early, so ListDir returned a part of the
    directory and RemoveAll reported success after deleting a part of it,
    or repeated pages for a token it had sent before.
  • s3fs multipart uploads and copies into Wasabi buckets with an
    AbortIncompleteMultipartUpload lifecycle rule failed, because the SDK
    can't parse the ISO 8601 date that Wasabi sends in x-amz-abort-date.
  • s3fs copies above 5 GiB sent the part checksums that a service returned
    for an upload created without a checksum algorithm, which services that
    check them can refuse as a mismatch of the checksum type.
  • s3fs Remove succeeds when DeleteObject answers 404 for an object that
    another client deleted after Remove found it, like Google Cloud Storage
    does where S3 succeeds.
  • s3fs RemoveAll deletes the objects one by one on a service that answers
    DeleteObjects with 501 Not Implemented, like Google Cloud Storage,
    and sends DeleteObjects only for the first batch then.
  • s3fs RemoveAll keeps the body of every DeleteObjects request below the
    1 MiB that Ceph RGW accepts, the server of Hetzner and DigitalOcean Spaces,
    which 1000 long keys exceeded.
  • The copy then delete fallback of fs.Move within a file system that is not
    local and has no native Move, like s3fs, refuses a destination that may be
    another Unicode normalization of the source name and has its size,
    modification time and permissions, like it refuses another case of the name.
    On Cloudflare R2, which matches keys by their Unicode normalization, the
    move copied the object onto itself and then deleted it.

v1.0.0-rc.4

v1.0.0-rc.4 Pre-release
Pre-release

Choose a tag to compare

@ungerik ungerik released this 01 Nov 13:57
d334bba

Fourth release candidate: copies and moves within sftpfs, smbfs, ftpfs and
other file systems that are not local no longer truncate or delete a file
that the destination reaches under another name, a move into a zip or tar
writer is refused instead of losing the source, ftpfs RemoveAll can no
longer be tricked into deleting through a link, EnsureRegistered checks
its prefix like Register, passwords stay out of httpfs errors, and more
Shift-JIS zip names decode.

Changed

  • fs.Move into a write-only file system, like a zipfs.Writer or
    tarfs.Writer, fails with an error wrapping fs.ErrWriteOnlyFileSystem
    before it copies anything. It removed the source as soon as its entry was
    in the writer's stream, but the archive is only written by Close, so
    a failing Close lost the moved files. Copy with fs.CopyRecursive,
    close the writer and remove the source after Close succeeded.
  • ftpfs RemoveAll fails for a directory whose LIST listing, which tells
    a directory from a symbolic link, has a line that the FTP client library
    dropped because it can't parse it, like the line of a FIFO, a device or
    a socket, or one with a five-digit year. Empty lines and the total N
    line of ls -l are fine. On servers with MLST support this is the
    listing of the parent of every directory whose DELE failed, on servers
    without it the listing of the removed directory. The check for an entry
    named -a runs after every such listing instead of once per directory.

Fixed

  • fs.CopyFile of a symbolic link onto the file it points to, of a file
    onto a link to it, or through a link to a parent directory, within one
    file system that is not local and has no native CopyFile, like sftpfs
    and smbfs, truncated the file before reading it. An existing destination
    is now compared with every link resolved, also between a
    SubFileSystem and its parent, and the copy is a no-op like for local
    files. The copy then delete fallback of fs.Move refuses such paths as
    the same file with an error wrapping os.ErrInvalid instead of removing
    the source.
  • fs.CopyFile of a file onto another hard link of it, or onto another
    case of its name on a case-insensitive server, within sftpfs, smbfs,
    ftpfs or another file system that is not local and has no native
    CopyFile, truncated the file before reading it (reproduced on Samba).
    These servers can't tell such a destination from another file, so
    a destination with the size, modification time and permissions of the
    source is now written as a new file in its directory that then replaces
    it with a move. That copy needs the permission to create, rename and
    remove files in the destination directory, which an overwrite in place
    doesn't, and the replaced file gets the owner and permissions of a new
    file. A copy onto a symbolic link replaces the file it points to and
    keeps the link, and when the move onto the destination fails after it
    removed the destination, the new file is kept and the error names it.
    The copy then delete fallback of fs.Move refuses a destination that
    only differs in case and has those attributes, and a move between
    a SubFileSystem and its parent that is not local uses the native
    Move of the parent, which renames on the server, except for a symbolic
    link, which is handled like between other file systems.
  • fs.Move of the root directory of a SubFileSystem to another file
    system copied the whole directory before it failed to remove the root;
    it is refused with an error wrapping os.ErrInvalid before anything is
    copied, like SubFileSystem.Move refuses it.
  • An ftpfs RemoveAll could delete the files that a symbolic link points
    to: a client that could write into the directory could make the client
    library drop the line of its link and add a forged directory line with
    the link's name through a file name with a line feed (see Changed).
  • On FTP servers without MLST support that expand glob characters in the
    path argument of LIST, like wu-ftpd and ProFTPD with UseGlobbing but
    without mod_facts, ftpfs listed another directory for a path with *,
    ? or [, so Stat and ListDir described its entries and RemoveAll
    could take a symbolic link for a directory and delete the files it points
    to. Such a path, and a relative one that begins with -, is now listed
    after a CWD to it with LIST without an argument, and the working
    directory is changed back; a failed change back closes the connection.
  • fs.EnsureRegistered registered a prefix with a slash or backslash
    before its ://, which fs.Register refuses, so after the last free
    its URIs were local paths. The prefix is refused with an error wrapping
    os.ErrInvalid before create is called, and so is a prefix alias of
    the created file system.
  • The errors of httpfs.New for an invalid prefix contained the password
    of a prefix with user info; the error for a prefix with a query also
    leaves out the query now. The errors of fs.CopyRecursive for
    a directory copied into itself redact passwords like the other errors.
  • zip names: an Info-ZIP Unicode Path field was ignored for Shift-JIS
    names where the ASCII second byte of a double-byte character is followed
    by the same letter, like アA日.txt or エリアA計画.xlsx, which then
    showed the CP-437 decoding of the stored name.

v1.0.0-rc.3

v1.0.0-rc.3 Pre-release
Pre-release

Choose a tag to compare

@ungerik ungerik released this 01 Nov 09:33
598e9e8

Third release candidate: the zipfs and tarfs readers and writers share
their entry info, conflict checks and directory creation instead of two
copies, backends share one NUL check, and the README is rewritten for a
first-time reader.

Added

  • fsimpl.ValidateNoNUL(subject, s) returns an error wrapping
    os.ErrInvalid for a path or name with a NUL character, next to
    fsimpl.CheckNoBackslash, for backends that can't store such names.
    sftpfs, webdavfs, dropboxfs and tarfs use it; their error messages are
    unchanged.

Changed

  • The root directory of a zip or tar archive with an explicit ./ or /
    entry has the header of that entry as FileInfo.Sys, a
    *zip.FileHeader or *tar.Header, like every other entry; it was nil.
    The root of an archive without such an entry still has no Sys.
  • The errors of zipfs and tarfs file systems after Close name the
    file system and its URI prefix, like httpfs and MemFileSystem:
    Tar reader filesystem with prefix tar://<id>: file system is closed.
    tarfs returned the bare fs.ErrFileSystemClosed, so compare with
    errors.Is(err, fs.ErrFileSystemClosed), not ==.
  • The README starts with a one-line pitch, an install section, a short
    example that runs one function on local disk, HTTP and S3, and the
    feature list. The go get lines of the backend READMEs and the connect
    how-to fetch the core module together with the backend, because a
    backend fetched alone in a fresh module can't resolve the placeholder
    version of the core module, and Go examples that use fs.* import the
    core module.

v1.0.0-rc.2

v1.0.0-rc.2 Pre-release
Pre-release

Choose a tag to compare

@ungerik ungerik released this 27 Oct 08:48
90e6538

Second release candidate: zip archives get one name rule for every writer
and UTF-8 names on read, and a copy, move or rename into a file system that
can't write a name, like a zip writer or an S3-compatible server, fails
before it writes anything instead of at that name.

Added

  • fs.ValidateNameFileSystem, an optional interface with ValidateName(name)
    for file systems that can't write some names that their separator allows.
    fs.CopyFile, fs.CopyRecursive, fs.Move, File.MoveTo and
    File.Rename check the names they write with it, also through a
    SubFileSystem or OverlayFileSystem to the file system that gets the
    writes, so they fail before they write anything instead of at the first
    such name. CopyRecursive checks the files and links that match its
    patterns, and every directory. File.MakeAllDirs checks the names of the
    missing directories, also the parent directories that a copy or move
    makes. Their errors wrap the error of ValidateName, which tells why.
    Existing entries are read with every name, and copied and moved with
    their names within the file system, which holds them. The write methods
    of a file system itself, like OpenWriter, are not checked. sftpfs,
    ftpfs, webdavfs, smbfs, s3fs, azureblobfs, dropboxfs and the zipfs and
    tarfs writers implement it with the names that their servers or formats
    can't write, see the READMEs: a backslash (unless
    Options.AllowBackslashInNames for sftpfs, ftpfs and webdavfs), a NUL
    character, at which an SFTP server would end a path, CR and LF, which
    would inject an FTP command, the characters that SMB refuses, the device
    names and trailing dots that Windows servers refuse, invalid UTF-8, which
    the remote backends don't write, control characters, which the XML
    listings of S3 and Azure Blob Storage can't hold, and trailing dots,
    which Azure removes.
  • fstest.RunConformance checks the ValidateName of a file system that
    implements fs.ValidateNameFileSystem: names that every file system
    writes are valid, errors wrap os.ErrInvalid, a copy to a rejected name
    writes nothing, and every accepted name of a probe list is written, read
    back and listed with that name.
  • fstest.MockFullyFeaturedFileSystem implements fs.ValidateNameFileSystem
    with the hook MockValidateName; without it every name is valid.

Changed

  • fs.Zip and ZipMemFiles reject the names that are not valid in a zip
    archive with an error wrapping os.ErrInvalid, not only the names that
    UnzipToMemFiles rejects: names that are not valid UTF-8, which zip
    readers decode as CP-437, that contain a control character like NUL, a
    line or paragraph separator, a bidirectional embedding, override or
    isolate, which can disguise an extension (evil\u202etxt.exe), or a
    colon, which marks a drive letter on Windows, and names longer than the
    65535 bytes of a zip header. The name of a FileReader that is not a
    MemFile has to be a clean, slash separated path (io/fs.ValidPath, not
    a//b.txt or dir/ for a file); the FileName of a MemFile is cleaned
    as before. archive/zip writes all of these names, except a name that is
    too long, which it rejects after adding it to the central directory.
    zipfs.Writer rejects the same characters and lengths in its cleaned
    paths. Names that only Windows can't extract, like what?.txt, are not
    checked.
  • fs.UnzipToMemFiles and zipfs.Reader return entry names as UTF-8: a
    name without the UTF-8 flag is taken from its Info-ZIP Unicode Path extra
    field if it has one that keeps the ASCII parts of the stored name and
    only replaces its bytes of another code page and the ? and _
    substitutes, without a control or bidirectional formatting character, so
    it can't give the entry another extension, directory or drive letter
    than archive/zip shows, also not one that only looks like another,
    else a name that is not valid UTF-8, like the umlauts of old Windows
    tools, is converted from CP-437, the encoding of names without the flag.
    archive/zip returns the stored bytes, which ZipMemFiles and
    zipfs.Writer now reject, so the MemFiles and files of such an archive
    couldn't be zipped again.
  • Copies and moves from another file system into a backend fail before
    they write anything at a name that ValidateName of the backend rejects,
    also where the server wrote it before: a name that is not valid UTF-8
    into sftpfs, ftpfs and webdavfs on Linux servers, a backslash into s3fs,
    which AWS S3 stores but S3-compatible servers reject, and Windows device
    names and trailing dots or spaces into smbfs, which Samba writes. Copies
    and moves within one of them keep these names.
  • tarfs.Writer rejects paths with a NUL character, which archive/tar
    failed to write without os.ErrInvalid, and paths that are not valid
    UTF-8, which the PAX format requires, with an error wrapping
    os.ErrInvalid. sftpfs rejects paths with a NUL character, at which the
    server would end the path and use another file.

Fixed

  • File.Rename, and fs.Move and File.MoveTo within one file system,
    check the new name like a copy into the directory does: on Windows a name
    that Windows writes to another entry, like report. to report,
    replaced that file, and names with one of < > " | ? * reached the file
    system. fs.CopyFile to a local name that the local file system doesn't
    write fails before it makes the parent directories, like fs.Move.

  • A zipfs.Writer path longer than 65535 bytes made the whole archive
    unreadable: archive/zip adds the name to its central directory before
    it rejects it, so Close returned no error and wrote a corrupt archive.

v1.0.0-rc.1

v1.0.0-rc.1 Pre-release
Pre-release

Choose a tag to compare

@ungerik ungerik released this 26 Oct 12:54
fb5aa79

First release candidate: file URIs follow RFC 8089 on every platform, copies
and moves refuse what would overwrite, misplace or leave their destination
instead of losing data (name collisions, invalid and reserved names, special
files, the same file through another path), ftpfs RemoveAll no longer
deletes through symbolic links on servers that show them, azureblobfs
handles blobs with snapshots and moves blobs natively, pinned to their
ETags, and File.URL is renamed to File.URI. All modules are tagged in
lockstep, the tools module is not tagged.

Changed

  • Only a :// with no slash or backslash before it is the scheme of a URI:
    a string like /cache/https://x is the local path /cache/https:/x
    instead of the Invalid file system. s3://bucket/key without
    a registered s3fs stays Invalid, like every URI of an unregistered
    scheme. fs.Register refuses a prefix with a separator before its ://,
    whose URIs would be local paths after Unregister, and so do the s3fs
    Options.Prefix check and the conformance suite.

  • File.URL() is renamed to File.URI(), fs.FileURLs to fs.FileURIs,
    and fsimpl.PathHelper.URL and LocalFileSystem.URL to URI. The value
    is a go-fs URI, which percent-encodes only %: names keep their spaces,
    ? and #, so it is no RFC 3986 URL to pass to net/url, an HTTP client
    or a browser. The value is unchanged, except for the file URIs of
    Windows and UNC paths, which follow RFC 8089 now, see below.

  • fs.ReadHeader and fs.ReadHeaderString take a ctx as first argument
    like the other functions that read content. It is checked before the file
    is opened and between the reads. A reader that fails with
    io.ErrUnexpectedEOF, like a truncated stream, is an error now instead of
    a short header.

  • fsimpl.ReadonlyFileBuffer, NewReadonlyFileBuffer and
    NewReadonlyFileBufferReadAll are renamed to ReadOnlyFileBuffer,
    NewReadOnlyFileBuffer and NewReadOnlyFileBufferReadAll, the spelling of
    every other read-only identifier.

  • File URIs follow RFC 8089. File.URI() (was File.URL()) of a Windows
    path is file:///C:/dir/file instead of file://C:/dir/file, and of a
    UNC path file://server/share/file, of the servers localhost and ~
    and of a server like C: file:////localhost/share/file, because as host
    localhost is a local path, ~ the home directory and C: the drive.
    Only the form file:// is recognized, the short forms file:/path and
    file:path of RFC 8089 are relative local paths. Parsing accepts
    file://localhost/…, on Windows also the old file://C:/… form, and maps
    file://server/share/… to the UNC path \\server\share\…. On other
    platforms a file URI with a host other than localhost resolves to the
    Invalid file system instead of a path relative to the working directory.
    So does a relative URI that v0 wrote or accepted, like
    file://data/uploads, which names the host data (on Windows the UNC
    path \\data\uploads). The hosts ., .. and ? name no host on any
    platform: file://./x resolves to the Invalid file system, also on
    Windows, where it would be the device path \\.\x. File.URI() of a
    relative path that can't be made absolute, because the working directory
    can't be determined, is file://./…, which names no file. file:// and
    file://localhost without a path have the empty path instead of the
    working directory: they resolve to the local file system, whose operations
    fail for the empty path with fs.ErrEmptyPath, and the Files derived from
    them, like by Join or Dir, have the empty path too, with the URI
    file://. A Windows long path of a drive or a UNC path keeps its prefix,
    \\?\C:\x has the URI file:////?/C:/x like in beta.3, because the
    prefix keeps names that Windows would normalize, like a trailing dot.
    Other paths of the device and file namespaces, like \\.\COM1,
    \\?\Volume{…}\x and \??\PhysicalDrive0, get a URI that names no file.
    On Windows a file URI with a host is a UNC path, so opening a File from
    an untrusted file URI can connect to that host over SMB, also for forms
    without a host like file:////server/share/x; check the resolved path,
    see ParseRawURI.

  • sftpfs, ftpfs and webdavfs reject a path with a backslash with an
    error wrapping os.ErrInvalid, in sftpfs also a symbolic link target
    and in ftpfs a listed link target that Stat follows.
    For their separator / the backslash is part of a name, but a server on
    Windows takes it for a separator and resolves .., so a name like ..\x
    from a SubFileSystem, an archive or CopyRecursive reached a file outside
    of its directory, like the backslash rule of smbfs. The new
    Options.AllowBackslashInNames of the three backends allows backslashes
    for servers that store them in names, like servers on Unix.

Added

  • azureblobfs.Options.DeleteSnapshots deletes the snapshots of a blob
    together with it in Remove, RemoveAll and Move. Without it, removing
    a blob with snapshots keeps the blob and returns an error wrapping the new
    azureblobfs.ErrSnapshotsPresent, RemoveAll checks the whole tree for
    snapshots before it deletes anything, and Move before it copies anything.
  • azureblobfs implements fs.MoveFileSystem: Move copies the blobs
    server-side and deletes the source after every copy succeeded. Every copy
    and delete is pinned to the ETag the source blob had when Move found it
    (x-ms-source-if-match, If-Match), so a blob that another client
    replaces during the move is kept, and Move returns an error saying that
    it changed while it was being moved. A source blob that another client
    deletes before its copy stops Move with an error wrapping
    os.ErrNotExist. Every copy is pinned to its destination too: to a
    missing destination, like every blob of a directory, with
    If-None-Match: *, onto an existing destination blob with If-Match and
    the ETag Move found. A blob that another client creates at the
    destination or below a moved directory, or a newer version of the
    destination blob, is not overwritten: Move stops with an error wrapping
    fs.ErrAlreadyExists (os.ErrExist) for it. Both errors copy nothing
    more and delete no source blob. When the SDK retries a copy whose answer
    was lost and the retry fails the destination condition against the copy
    Azure already made, Move recognizes the completed copy of the source
    blob it found (copy source, size, Content-MD5, completed after the source
    was last modified) and finishes the move. A copy of a snapshot or version
    of the source (a snapshot or versionid parameter in the copy source)
    is not taken for that copy. A source blob that another client deletes
    after its copy, or whose delete the SDK retried after a lost answer, is no
    error also when the pinned delete is answered with 412 instead of 404, as
    Azurite does: Move looks the blob up after a 412 and goes on if it is
    gone. Only a move within one file system
    is pinned; fs.Move to another container or file system copies and calls
    RemoveAll, which isn't. The generic move copied first and
    then failed to delete a source with snapshots, after it had replaced the
    destination.
  • fsimpl.CheckNoBackslash returns the error of the backslash rule of the
    remote file systems with the separator /, which ftpfs, sftpfs,
    webdavfs and smbfs share.

Fixed

  • fs.CopyFile and fs.Move into an existing directory joined the name of
    the source unchecked: a name like ..\evil.txt of a source on a file
    system with the separator / was written outside of the directory on
    a file system with the separator \, and Move removed the source. On
    Windows NUL or a:b went to a device or an alternate data stream. A name
    that is not one valid name in the directory is now an error wrapping
    os.ErrInvalid, like for CopyRecursive.

  • ftpfs RemoveAll refuses a directory whose name its listing lists more
    than once, like for a file whose name contains a line feed followed by
    a forged line that lists a directory with the name of a link. On servers
    without MLST support the listing is all that tells a directory from
    a link, so it deleted the files that such a link points to. Servers that
    hide dotfiles from LIST, like vsftpd by default, hide them from ftpfs
    too; this is documented.

  • CopyRecursive and Move fail with ErrEmptyPath when the source or the
    destination has the empty path, like a file URI without a path (file://,
    file://localhost). Their same-file checks took that path for the working
    directory: copying the working directory to file:// returned nil without
    copying anything, and so did Move from file:// to file://localhost.

  • ftpfs on servers without MLST support: Stat, Remove, RemoveAll,
    Move and MakeDir find a symbolic link whose name contains ->, and
    ListDir and ListDirRecursive of such a link to a directory list the
    directory. The FTP client library cuts the LIST line of a link at the
    first ->, so ftpfs reported such a link as missing, and RemoveAll
    returned nil and kept it. ListDir still names the link by the part
    before the first ->.

  • fs.CleanFilePath and fs.JoinCleanFilePath didn't decode the
    percent-encoded characters of a URI, unlike File and fs.ParseRawURI:
    file:///tmp/a%25b was the path /tmp/a%25b instead of /tmp/a%b, and
    s3://bucket/a%20b the key a%20b instead of a b. They resolve the
    first part like File now, the other parts are names, used verbatim.
    LocalFileSystem.CleanPath and SplitPath decode a file URI too.

  • File.TrimExt trimmed the string of the File instead of its path, so it
    could cut at a dot before an encoded separator %2F of a URI, or on
    Windows at a dot in a directory or host name of a file URI, like
    file://fileserver.corp/share/README, wh...

Read more

v1.0.0-beta.3

v1.0.0-beta.3 Pre-release
Pre-release

Choose a tag to compare

@ungerik ungerik released this 24 Oct 13:58
71d452e

Third beta: an empty indent of the …Indent writers puts every element on its
own line, and azureblobfs handles unexpected answers without panicking. All
modules are tagged in lockstep, the tools module is not tagged.

Changed

  • WriteJSONIndent and WriteXMLIndent of File and MemFile, and
    NewMemFileWriteJSONIndent/NewMemFileWriteXMLIndent, put every element on
    its own line without indentation when indent is empty, instead of writing
    the compact output of WriteJSON/WriteXML. For JSON that is the output of
    beta.1's WriteJSON(ctx, v, "") again. For XML the newlines are new and are
    read back as part of mixed content (character data next to child elements);
    WriteXML still adds no whitespace. A NUL byte, which is invalid in XML,
    directly before a < in content the encoder writes without escaping
    (,innerxml, ,cdata, ,comment, names and xml.Marshaler tokens) is
    removed together with the line markers.
  • Backend dependencies are bumped: azureblobfs (azcore v1.23.3, azblob
    v1.8.2), s3fs (AWS SDK v1.47.4, service/s3 v1.114.5, transfermanager
    v0.4.19), sftpfs (pkg/sftp v1.13.12) and smbfs (geoffgarside/ber v1.2.0,
    hashicorp/go-uuid v1.0.4).

Fixed

  • azureblobfs returns an error instead of panicking with a nil pointer for a
    download answered with 304 Not Modified (azblob v1.8.2 returns it without
    body and without error) and for a listing answer without a Blobs element.
  • The reader of azureblobfs OpenReader returns the bytes at its position
    when a server ignores the Range header, instead of the start of the blob.
  • azureblobfs WriteAll uploads at most 4 blocks in parallel like
    OpenWriter, azblob v1.8.1 raised its default to 8 to 96.

v1.0.0-beta.2

v1.0.0-beta.2 Pre-release
Pre-release

Choose a tag to compare

@ungerik ungerik released this 23 Oct 06:41
b15cb0a

Second beta. It fixes the bugs of a full review of beta.1 (data loss,
security, crashes) and settles the API decisions that freeze with v1.0.0.
Most breaking changes fail to compile, so the compiler finds the call sites;
docs/MIGRATION_v1.md lists them in "Upgrading from v1.0.0-beta.1". All
modules are tagged in lockstep, the tools module is not tagged.

Changed

  • Constructors never register implicitly. New…/Dial… return the file
    system, and an error where construction can fail, and don't register it; …AndRegister variants register
    and return only an error. Every constructor that used to register under a
    plain name changed its signature, so old call sites don't compile instead of
    silently losing the registration: fs.NewMemFileSystem(opts *MemFileSystemOptions, initialFiles...) (ID, separator, volume and
    read-only are options; WithID, WithVolume and NewSingleMemFileSystem
    are gone), zipfs/tarfs NewReader/NewWriter(file, id),
    multipartfs.New(form, id) and multipartfs.NewFromRequest (was
    FromRequestForm), s3fs.NewLoadDefaultConfig and
    azureblobfs.NewFromConnectionString. Temporary file systems are used with
    New, fs.Register and defer f.Close().
  • Registry. A URI matches a prefix only at a boundary (the URI ends, the
    prefix ends with /, or / or the separator follows), and the longest
    match over prefixes and aliases wins, so s3://logs no longer serves
    s3://logs-archive/… and ftp://user@files no longer serves
    ftp://user@files.example.com/…. Register returns an error
    (ErrAlreadyRegistered) when another file system holds the prefix and is
    not reference counted any more; Unregister and IsRegistered compare
    instances. fs.EnsureRegistered is an atomic get-or-create with one shared
    connect for concurrent callers and reference counted free functions.
    Close always unregisters.
  • Per-instance options in every backend, no mutable package config.
    s3fs.New(client, bucket, *Options), azureblobfs.New(ctx, client, *Options), dropboxfs.New(ctx, token, *Options), sftpfs.Dial(ctx, address, *Options) (password, public keys, agent and keyboard-interactive
    via Auth, host key callback that fails closed, timeouts, keep-alive,
    retries, DialContext), ftpfs.Dial(ctx, address, *Options) (credentials
    moved into the options), smbfs Options.DialContext. The package
    variables s3fs.MultipartUploadThreshold/MultipartDownloadThreshold,
    sftpfs.MaxConnectRetries/InitialRetryBackoff/URLHostKeyCallback and
    httpfs.Client are gone; all DefaultPermissions/DefaultDirPermissions
    are constants. httpfs has an exported FileSystem type with
    New(prefix, *Options) and NewAndRegister, for example to use an
    authenticating client for https://api.example.com/; its Close unregisters it,
    Default and DefaultTLS stay registered.
  • Error contract. The typed errors (ErrDoesNotExist, ErrPermission,
    ErrAlreadyExists, ErrIsDirectory, ErrIsNotDirectory and the new
    ErrDirectoryNotEmpty) are created for a FileReader; File() returns
    (File, bool), the new FileReader() the passed reader, and every typed
    error matches errors.Is(err, fs.ErrIsDirectory{}) and so on. They stay
    comparable for non-comparable readers like MemFile, so errors.Is never
    panics. ErrEmptyPath is a constant that no longer wraps os.ErrNotExist,
    so Remove("") is an error. Files of unregistered prefixes report
    ErrInvalidFileSystem with the URI (password redacted) instead of
    "write-only". New sentinels ErrFileSystemsDoNotMatch and
    ErrAlreadyRegistered. Error messages never contain passwords, SAS
    signatures or URL queries.
  • Move, Rename and CopyFile onto an existing destination behave the same
    on every file system: an existing file is replaced, an existing directory
    is an error wrapping os.ErrExist (ErrIsDirectory for CopyFile) and is
    never merged or deleted, a directory onto a file is ErrIsNotDirectory,
    moving a directory into itself is an error wrapping os.ErrInvalid.
  • Implementer interfaces. MoveFileSystem.Move and
    TruncateFileSystem.Truncate take a ctx; SymbolicLinkFileSystem has
    Lstat instead of IsSymbolicLink; XAttrFileSystem.SetXAttr takes the
    portable XAttrFlags (XAttrCreate, XAttrReplace); PermissionsFileSystem
    embeds FileSystem; RenameFileSystem and ListDirMaxFileSystem are
    removed (Rename is a Move within the directory). New WriteAborter, which
    the package uses to discard uploads that commit on Close when a copy fails,
    and URIFileSystem for file systems whose paths are escaped URIs.
    fsimpl.PathHelper is no longer embedded as an exported field and lost
    IsAbsPath, AbsPath and IsHidden. Event has go-fs owned constants
    (EventCreate, …) instead of fsnotify values, and the callbacks of one
    watch are called serially in event order.
  • File API. File.Rename/Renamef take a ctx (without native move they
    copy); File.Lstat is new and ReadSymbolicLink returns the raw target
    string; FileReader gains Stat and IsSymbolicLink; Glob yields
    iter.Seq2[File, error] with pattern, listing and ctx errors, MustGlob is
    removed; WriteJSON/WriteXML(ctx, input, perm...) and
    WriteJSONIndent/WriteXMLIndent(ctx, input, indent, perm...) (same for
    MemFile and NewMemFileWrite*); ServeFileHTTP(w, r, file, contentType string); TempFile(ext)/CreateTempFile(ext);
    ContentHashFuncFrom(newHash func() hash.Hash); CopyFileBuf(ctx, src, dest, buf []byte, perm...); fs.ReadAll(ctx, r)/fs.WriteAll(ctx, w, data) (were ReadAllContext/WriteAllContext); ReadSeekCloser is
    ReadAtSeekCloser.
  • fstest no longer depends on testify, derives every name from the seed,
    has Config.Skip and many new contract checks (errors, closed file systems,
    cancellation, overwrite semantics, moves into itself, content above 1 MiB,
    WriteAborter, URI boundary and round trip). The Docker helpers moved to
    internal/dockertest.
  • s3fs uses feature/s3/transfermanager instead of the deprecated
    feature/s3/manager; smbfs uses the maintained github.com/cloudsoda/go-smb2
    fork (GO-2026-5051); dependencies are bumped (x/net, x/text, x/crypto,
    x/sys, AWS SDK, jlaffaye/ftp v0.2.4, Dropbox SDK v6.6.2).
  • Copies never take over setuid, setgid and sticky bits. CopyFile,
    CopyRecursive, emulated moves, the overlay copy-up and
    MemFileSystem.CopyFile give the destination only the 9 permission bits of
    the source; pass perm to set special bits. A copy from a read-only file
    system (uploads, archive entries, StdFileSystem) gets the owner write bit,
    so an upload copies as 0644 instead of 0444. NewFileInfo (Local,
    StdFileSystem, sftpfs, smbfs) reports the special bits.
  • Directory links in recursive walks. ListDirRecursive (native and
    emulated) never descends into a symbolic link to a directory, like
    filepath.WalkDir: the link itself is passed to the callback with
    IsSymlink true and IsDir false; a link at the start of the listing is
    followed. CopyRecursive and moves recreate a link to a directory as a
    link with its verbatim target within one file system instance that
    supports links. Between different instances, or if the destination can't
    create links, they fail before writing anything with an error wrapping
    errors.ErrUnsupported; links to files are copied as files. Copies never
    write through a symbolic link below the destination root, a link where a
    file or directory is to be written is an error wrapping os.ErrExist;
    this assumes nobody else changes the destination during the copy.
  • XAttr errors. XAttrCreate on an existing attribute wraps
    os.ErrExist; XAttrReplace and GetXAttr/RemoveXAttr of a missing
    attribute wrap os.ErrNotExist (Local and MemFileSystem); fstest checks it.
  • Archive names. fs.Zip and ZipMemFiles reject names that escape
    with .., names with a backslash and absolute names (the leading slash of
    a MemFile name is dropped) with an error wrapping os.ErrInvalid, so every archive
    they write unzips with UnzipToMemFiles; zipfs.Reader skips symbolic
    links, devices and FIFOs like tarfs.
  • Root directories. Remove and RemoveAll of the root return an error
    wrapping os.ErrInvalid in every file system, also for relative paths of
    the root like "." in sftpfs and ftpfs, instead of deleting the whole
    bucket, container or server tree in s3fs, azureblobfs, sftpfs and ftpfs and
    calling os.RemoveAll("/") for the root of a local volume.
  • Paths. Only a ~ at the start of the first part of a Local path means
    the home directory, a directory named ~ is written ./~; a SubFileSystem
    stores relative link targets with .. as paths of the parent; smbfs paths
    and link targets containing \, and link targets with a drive letter, are
    errors wrapping os.ErrInvalid; TempFile returns InvalidFile for an extension with a
    path separator; StdFS and SubFileSystems of Local apply the os.DirFS
    name rules (Windows device names, \, :, NUL) to the local file system
    only.
  • Same file under two names. LocalFileSystem.Move renames a file onto
    its own directory entry under another spelling (case, Unicode
    normalization) and moves a file with more than one hard link through a
    temporary .gofs-move-* name, so it never removes the only link of a file;
    moves through bind mounts, symbolic links to a parent or a SubFileSystem
    onto the same file never copy and remove it, also through the local layers
    of an OverlayFileSystem. Moving a symbolic link onto the file it points
    to is an error wrapping os.ErrInvalid, like mv reports "are the same
    file", in Local, Mem, sftpfs, smbfs and the move emulation; CopyFile of a
    file onto itself through another path is a no-op. fs.Move of a...
Read more
⌂ 换网址