8000 feat(smb): import files added over the SMB share by adeelahmad · Pull Request #519 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(smb): import files added over the SMB share - #519

Merged
adeelahmad merged 7 commits into
mainfrom
claude/project-thread-cmjahx
Oct 18, 2026
Merged

adeelahmad merged 7 commits into
mainfrom
claude/project-thread-cmjahx

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: the SMB share was read-only. Copying a file onto it from Finder, Windows Explorer or smbclient was refused.

After: a file copied into a collection's folder on the SMB share is imported when it's closed, as a web upload is. A new folder under Collections is a new collection, and a file anywhere else in a namespace goes to its default collection.

How: SMB creates, writes, renames and closes go to the same share_import.Adder that S3 and WebDAV use (#408). The file is written to the uploads disk while it's open and handed to uploads.take() on close, so it gets the upload's permission, type and size checks, the namespace's pipeline and dedupe. Files of a type Lens doesn't take are refused when they're created. Files over the upload limit are cut off as they're written and dropped. Files deleted on close, or left open when the client goes away, are never imported. The system's own files (.DS_Store, Thumbs.db, Office's ~$ files) are kept aside, and renaming a temporary file to a real name imports it. Adder.check now checks a file's type before its size is known, which also helps S3 multipart and chunked WebDAV.

Motivation and Context

Adeel asked that any file added through Lens's file protocols be imported automatically. #408 did S3 and WebDAV; this does SMB, and NFS follows.

Steps to reproduce (if appropriate):

Turn on the SMB share, then smbclient //host/lens -p 1445 -U <key-id>%<secret> -c 'cd pods/Collections/Talks; put talk.pdf' and look at the Talks collection.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests: tests/domain/test_smb_writes.py (6), test_smb_share.py updated. ci/local-ci.sh: backend, Next.js, pre-commit and the upgrade check pass.
  • My change requires documentation updates, and I have updated docs/ accordingly (docs/smb.md, Adding files; docs/file-tree.md).
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

Done questions (AGENTS.md)

  • Goal: SMB writes import; NFS is the last PR on the thread. Merged on green.
  • Agents: any SMB client an agent runs (smbclient, impacket) adds files; smb.add_files is in the settings API.
  • Zero setup: nothing new to install; it works as soon as the SMB share is on.
  • Fewest clicks: drag files in. Collections are made from folder names.
  • Configurable: smb.add_files (on) is a switch in Settings, SMB share; not in the wizard.
  • Light: no new dependency or service; bodies go to disk as they're written.
  • Private and secure: same permission as a web upload, same size cap while writing, Lens's own files can't be overwritten, renamed or deleted. Threat model (P-SMB, entry point) updated in md, yaml and json.
  • Cost: no model calls beyond the namespace's normal pipeline.
  • User decides: the share stays off until an admin turns it on; one switch makes it read-only again.
  • Upgrades: no stored-data change; the new setting is read through DEFAULTS.
  • Honest: README built list and docs/requirements.md name the tests. Tested with impacket's client and Samba's smbclient, not with Finder or Explorer themselves.
  • Tests, docs and generated files: make openapi regenerated openapi.json and the client.
  • Open standards: SMB2. No new dependencies.
  • Reported in the thread; refine later: SMB 3 encryption on the wire, and deleting or renaming assets through the share.
  • Reuse: the SMB server Lens already runs and the share_import adder from feat(shares): import files added over S3 and WebDAV #408.

Generated by Claude Code

A file copied into the SMB share is written to the uploads disk while
it's open and imported when it's closed (share_import.Adder.begin and
finish), with the same permission and checks as an upload. MKCOL-style
folder creates under Collections make collections; renaming a file kept
aside imports it; deleting one removes it. Files of a type Lens doesn't
take are refused at create, files over the upload limit are cut off as
they're written and dropped, and files deleted on close or left open
when the connection ends are never imported.

smb.add_files (on) makes the share writable; off, it's read-only as
before. Adder.check now checks a file's type even before its size is
known (S3 multipart, chunked WebDAV, SMB creates).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013sC1p4dJXjteytbxDXnk5g
@adeelahmad adeelahmad self-assigned this Oct 17, 2026
…-cmjahx

# Conflicts:
#	CHANGELOG.md
#	threat-model.yaml
…-cmjahx

# Conflicts:
#	CHANGELOG.md
#	README.md
#	threat-model.yaml
@adeelahmad
adeelahmad merged commit 167b934 into main Oct 18, 2026
12 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-cmjahx branch October 18, 2026 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0