Skip to content

v1.25.0

Choose a tag to compare

@gmpassos gmpassos released this 15 Oct 22:32
· 139 commits to master since this release
5039bfb

Static files: virtual file and directory aliases, defined by .aliases files
inside the served directory tree (see the README section
"Static files: .aliases").

  • StaticFilesAliases: a middleware in front of the static files handler.
    It rewrites a request without a physical file to its alias target: exact
    file alias, directory prefix, pattern (*, ?, **/) or overlay (./).
    • The physical path always wins, so existing paths are served as before.
    • Aliases can chain (max 8 levels, each entry once per chain), and cycles
      are ignored.
    • Patterns are matched without backtracking blow-ups (memoized, no
      RegExp).
    • Targets can't escape the .aliases directory (.. and absolute paths
      are rejected), and symlinks follow the existing root containment.
    • A virtual directory without a trailing / is redirected with a 302.
    • .aliases files (of existing directories), missing directories and
      resolutions are cached and re-checked every 10s, in bounded caches
      (evicting the oldest entries). A cached resolution costs ~130ns, and a
      path without any applicable alias ~300ns.
    • An aliased file goes through the same pipeline as a physical file
      (response cache, gzip, Cache-Control, cross-origin and cookieless
      headers), sharing the physical path's cached response.
  • .aliases files are never served: they respond 404. Before, a
    .aliases file in a served directory was served like any other file.

Also in this release (1.24.1, not released separately)

  • Fix: DBObjectDirectoryAdapter: selectAll and selectByIDs read all
    their object files in parallel, so concurrent selects of a large table
    opened thousands of files at once (not a leak, but an unbounded burst),
    failing with Too many open files (errno = 24) under a low limit (macOS
    default: 256). The reads are now limited by a FileLimited semaphore (50),
    in batches of that limit per select.
    • DBObjectDirectoryAdapter.fileLimited: the shared semaphore, tunable with
      setSemaphoreLimit (FileLimited is also exported by
      bones_api_db_directory.dart).
    • An object deleted while a select waits to read it is skipped (no
      existsSync check before the read: a missing file reads as null),
      and concurrent deletes of the same object delete it once (the others
      delete nothing, without an exception).
  • FileLimited.readAsString: like File.readAsString, under the semaphore.
  • Fix: FileLimited: an operation in flight while setSemaphoreLimit
    replaced the semaphore released the new one (raising it above its limit);
    it now releases the semaphore it acquired.

Pull requests: #186, #187.