feat(nfc): an NFC page for the tag dumps the game's NFC tab lists #49
No reviewers
Labels
No labels
area/build
area/install
area/saves
area/tooling
area/ui
area/updates
ci: approved
good first issue
gpu/amd
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
platform/linux
platform/steam-deck
platform/windows
priority
critical
priority
high
priority
low
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/LongshotLauncher!49
Loading…
Reference in a new issue
No description provided.
Delete branch "airdamien/LongshotLauncher:feat/nfc-tags"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
Longshot is getting an NFC tab that gives the game NFC tags from files in a folder of the player's (MagicBeanDev/Longshot#280). Players need a way to put their tag dumps there without finding a hidden folder: this adds an NFC page to the launcher for it.
What changed
Core/NfcTags.cs: the folder (LONGSHOT_NFC_DIR, else%LOCALAPPDATA%\Longshot\nfcon Windows,$XDG_DATA_HOME/longshot/nfcon Linux: the same rule as the game'shost/nn_nfp.c), listing, checking a dump (.binof 532, 540 or 572 bytes; a Flipper Zero.nfc; the two marks of a figure's NTAG215), adding (a name that is taken is never replaced: the same bytes are left, others go in asName (2).bin), deleting. Written throughAtomicFile.Core/NfcReader.cs: reading a tag with a Nintendo Switch 2 Pro Controller over USB (Windows, WinUSB): the reader's commands behind a send-and-answer delegate, so the checks drive them with a pretended controller. Read only: a write command cannot be built.App/ViewModels/NfcViewModel.cs,App/Views/NfcView.axaml,NfcDeleteView.axaml: the page. Add files (many at once), add a folder (with the folders under it), drop files or folders on the page, scan a tag, delete one or several (asked first), open the folder.App/Views/HomeView.axaml,HomeViewModel.cs,MainViewModel.cs: an NFC card under the saves' on the home, and an NFC tags link on the home before any build exists (the folder does not wait for a build).tests/launcher_core/NfcChecks.cs,NfcReaderChecks.cs: 119 checks at4c77d3c6(116 on Windows: three are Linux only), on pretended tags built in code. No real dump is in the repository, and CONTRIBUTING.md says none may be.docs/nfc.md, README.How it was tested
dotnet build LongshotLauncher.slnx: 0 errors (Windows 11, .NET SDK 10.0.201), at the first commit (5c1c0366).The NFC checks alone, at the first commit (
5c1c0366):NFC ONLY: 110 checks passed. The whole oftests/test_launcher_core.pyhas not run green here: on this Windows PC it stops inSelfUpdateChecksbefore reaching them, and does so onmaintoo (a Linux path in that check); CI on Linux is where the whole suite runs. To run them alone I madeMaincall onlyNfcChecks(); NfcReaderChecks();in a copy that is not committed.On screen (the screenshot below): the page listing three pretended tags and one file that is no dump, from a scratch
LONGSHOT_NFC_DIR.By the author, on their own files: adding a folder of folders (before
921ac746changed how a folder is walked: links to folders are no longer gone into).On Linux (.NET SDK 10.0.404), by HumanBean at
4c77d3c6(main merged in):dotnet build LongshotLauncher.slnx0 errors, Debug and Release with-p:RestoreLockedMode=trueas CI; the wholetests/test_launcher_core.py --strict --longshot <Longshot main>:launcher core: 934 checks passed, of them 119 NFC checks (counted in a copy that is not committed);tests/test_release.py: 28 tests OK. No window was opened there: the page and drag and drop were not run on Linux.Scan a tag, by the author on a real controller (a Nintendo Switch 2 Pro Controller, firmware 1.1.5, over USB, Windows 11): a figure's tag held on the controller was read and saved into the folder as
Scanned <ID>.bin.Not tested: the page on Linux (the scan is Windows only and its button is disabled there); a scan's other ends on real hardware (no tag in time, a tag that is no figure's, the controller held by another program) beyond the checks' pretended controller; drag and drop was built and compiled, and tried by the author only.
Screenshot
The NFC page, this PR:
Notes for the reviewer
...\Longshot\nfc), beside the save backups'...\Longshot\oot-save-backups.🤖 Generated with Claude Code
WIP: feat(nfc): an NFC page for the tag dumps the game's NFC tab liststo feat(nfc): an NFC page for the tag dumps the game's NFC tab listsScan a tag was run by the author on a real Switch 2 Pro Controller over USB: a figure's tag was read and saved into the folder. With that, the page's functions have all been used on real files and hardware; the title's WIP is off. Still for CI: the whole core suite (it does not run on the author's Windows PC, nor does main's).
Thanks: the core is careful (the checks on fake tags, nothing written over, read-only commands,
AtomicFile), and the folder rule matches the game'shos_nfc_dir()in MagicBeanDev/Longshot#280.Must change: dropping files on the NFC page looks refused by the window's own drag handler (inline on
Views.cs). The PR advertises the drop, so this blocks.Should change: the "first 256 by name" note doesn't match how the game in MagicBeanDev/Longshot#280 caps the list. Adding a folder runs on the window's thread.
Nits: inline.
CI: run 166 (
Compile and test,Conventional Commit title) is still pending on this head, so the whole core suite hasn't run anywhere yet.@ -0,0 +86,4 @@}/// (the game takes the first 256 by name: said once there are more)public bool TooMany => Rows.Count(r => r.Valid) > NfcTags.Most;As written in MagicBeanDev/Longshot#280, the game doesn't take "the first 256 by name".
add_file()stops atNFC_MAXwhile the folder is still being read, and only then doeslist_files()qsortit, so past 256 the game keeps whichever 256 the directory gave it first. It also counts every.bin/.nfcthat isn't akey_file, dumps or not, whileTooManycountsValidrows only.The right fix is in the game: sort first, then cap. After that, this should count every row, not only the valid ones (or the game should skip non-dumps before capping). Either way, this text,
NfcTags.Most's comment and docs/nfc.md ("uses the first 256") should say what the game really does.@ -0,0 +192,4 @@return;}IReadOnlyList<NfcTagAdded> done;try { done = NfcTags.Add(Folder, files); }NfcTags.Add, andNfcTags.FilesUnderinAddFolderAsync/AddDropped, run on the window's thread. A player who picks a big folder (Downloads, a whole drive, a OneDrive folder) gets a frozen window while it is walked recursively and every candidate is read. Suggest doing the enumeration and the copies inTask.Run, asScanAsyncalready does, with the buttons off while it runs.@ -0,0 +239,4 @@},};}catch (Exception e) when (e is DllNotFoundException or EntryPointNotFoundException or IOException)Nit: anything else thrown on the scan's thread, such as a
Win32Exception/SecurityExceptionfrom the registry read inGuids()or anSEHExceptionfrom a P/Invoke, faults the discarded_ = ScanAsync()task. The player then sees the spinner disappear with no message. A finalcatch (Exception e)that putse.MessageinReportwould cover that.@ -86,0 +93,4 @@{InitializeComponent();DragDrop.SetAllowDrop(this, true);AddHandler(DragDrop.DragOverEvent, (_, e) => e.DragEffects = DragDropEffects.Copy);This handler won't be the last to set
DragEffects.DragOverbubbles from here up toMainWindow, whose ownDragEnter/DragOverhandler (MainWindow.axaml.cs,Drag(e, true)) runs after this one and setse.DragEffects = DragDropEffects.None, becauseMainViewModel.AcceptsDropispage is FilesStepViewModelonly. When the last effect is None, the OS (OLE on Windows, XDND on X11) treats the target as refusing the drop and doesn't deliverDrop, soAddDroppedshouldn't be reached, and the cursor shows "no drop" over the page.If you did see a drop work, please say on which OS. Otherwise, the smallest fix that keeps one path for drops: remove these two handlers, make
AcceptsDrop => page is FilesStepViewModel or NfcViewModel, and haveMainViewModel.Dropcallnfc.AddDropped(paths)for that page. (Check that the window's "drop here" overlay text, if it names game files, fits this page too.)@ -0,0 +40,4 @@public static string Folder(Platform platform, Func<string, string?>? getenv = null){getenv ??= Environment.GetEnvironmentVariable;if (getenv(Variable) is { Length: > 0 } set) return Path.GetFullPath(set);Nit:
Path.GetFullPath(set)resolves a relativeLONGSHOT_NFC_DIRagainst the launcher's current directory. The game uses it as given, andMakeGameCommandstarts the game withWorkingDirectory = folder(the build's folder), so with a relative value the page and the game would use different folders. Either leave a relative value as it is and say in docs/nfc.md that it must be absolute, or refuse a relative one.Pushed
2644cdc0on top of5c1c0366, one commit for the points of the review (#49 (comment)). Not rebased: main's only new commit (README's Discord link) doesn't conflict.NfcView's ownDragOver/Drophandlers are removed.MainViewModel.AcceptsDropis nowpage is FilesStepViewModel or NfcViewModel, andMainViewModel.Drophands the NFC page's drops toNfcViewModel.AddDropped, so there is one path for drops. The window's overlay text was step 1's ("Drop your game file to check it"): it's nowDropText, which says "Drop NFC tag dumps, or folders of them, to add them" on this page.PageraisesAcceptsDrop/DropTextwhen it changes.TooManyText,NfcTags.Most's comment and docs/nfc.md now say whathost/nn_nfp.cat MagicBeanDev/Longshot#280's head (ea2cbd4b) does:add_file()stops at 256 while the folder is still being read andlist_files()sorts only after that, so past 256 the game keeps whichever files the folder gave it first. It counts every.bin/.nfcthat isn't akey_file, including files that aren't dumps.TooManynow counts every row (Rows.Count), the same files the game counts. The fix belongs in the game (sort, then cap) in MagicBeanDev/Longshot#280; Longshot isn't changed here. Once it's in, the text can say "the first 256 by name" again.AddAsync. It runs the search (FilesUnder, recursive) and the copies (NfcTags.Add) inTask.Runand returns to the window's thread for the report, the toast andReload. While it runs,Addingturns off Add files…, Add a folder… and Delete selected. A card with a spinner shows "Adding 40 of 120 files…", updated every 20 files throughUi.Post. A late update is dropped once that add is over. Any other exception is caught and shown on the page, and the busy flag is cleared infinally.ScanAsyncnow ends withcatch (OperationCanceledException) {}and acatch (Exception e)that puts "The scan stopped: …" inReport.LONGSHOT_NFC_DIR(nit). The game uses the value as given and is started in the build's folder, soNfcTags.Foldertakes an optionalgameFolder. A fully qualified value is used as before. A relative one is resolved againstgameFolder, and the page passes the default build's folder. With no build yet, a relative value is ignored and the usual folder is used. docs/nfc.md and the README say to give it as a full path.NfcCheckshas three new checks: relative with a build, relative with none, and full with a build.Something else I found, not changed here: on Linux,
GamePlay.Environmentremoves everyLONGSHOT_*variable before it starts the game (Dropped, the same as make_game'sGAME_ENV_DROP). SoLONGSHOT_NFC_DIRset for the launcher never reaches a game the launcher starts on Linux: the page would use that folder and the game the default one. The README's "for the game and the launcher alike" isn't true there yet. Either letLONGSHOT_NFC_DIRthrough or say so in the docs. That's for you to decide.Not built or tested: nothing was built, run or tested on this PC (no
dotnet, no checks). The C# was checked by reading only. CI is the first build. Drag and drop needs a run on both Windows and Linux (drag files and a folder onto the NFC page, then onto step 1), and so does adding a big folder (the window should stay responsive and the progress should move). The description's "110 checks" is now 113.Re-review of
2644cdc0only (the fix commit on top of5c1c0366), by reading: nothing was built or run here.Resolved from the last review (#49 (comment)):
NfcView's handlers gone, the window's ownDragEnter/DragOver(the window hasDragDrop.AllowDrop="True") give Copy throughAcceptsDrop, which now takes the NFC page, andDrophands the paths toAddDropped. The overlay bindsDroppingandDropText, both raised on page change. Step 1's path is unchanged.AddAsyncstarts on the window's thread (a command or the window's drop handler), so everyReport/Reload/ShowToastafter anawaitis back on it. Onlyfind,NfcTags.Addand the lazycountedrun inTask.Run, andcountedtouches nothing butUi.Post.SetAdding(false)is infinally, so the buttons come back on every path.TooMany(Rows.Count, fromFilesIn/IsCandidate) and the texts matchhost/nn_nfp.cat MagicBeanDev/Longshot#280's head (ea2cbd4b):add_file()stops atNFC_MAXwhile the folder is read,qsortruns after it, andkey_is skipped regardless of case.LONGSHOT_NFC_DIR:hos_nfc_dir()uses the value as given andGamePlay.StartInfosetsWorkingDirectory = folder, so resolving it against the build's folder is right on Windows. A newNfcViewModelis made on eachShowNfc, soFolderdoesn't go stale.OperationCanceledExceptionand a finalcatch (Exception)are in place. The earlier filtered catches don't make them unreachable.Home.Default?.Entry.Folder,Ui.Post,Command.Changed,ShownPath.Of(string?),NfcTags.Add(string, IEnumerable<string>), thec:namespace forSpinner). The three new checks are in the existingNfcChecks(), next to the other folder checks, and match the code.Must change: on Linux,
GamePlay.Environmentdrops everyLONGSHOT_*variable before it starts the game, so aLONGSHOT_NFC_DIRset for the launcher never reaches the game. The page then shows and fills one folder while the game reads the default one. The README ("for the game and the launcher alike"), the Either row in docs/nfc.md and the new paragraph on relative paths all describe a behaviour that isn't true on Linux. Comments inline.Nit: inline.
CI: "Compile and test" was skipped on
2644cdc0(run 175; only "Conventional Commit title" ran), so nothing has compiled this commit yet. It still needs that, and a drag-and-drop run on Windows and Linux.@ -0,0 +197,4 @@/// in a toast, and on the page each file skipped or renamed, with why. None: says `none`async Task AddAsync(Func<IReadOnlyList<string>> find, string none, string? from = null){if (Adding) return;Nit: a drop while an add is running still shows the "Drop NFC tag dumps… to add them" overlay (
AcceptsDropdoesn't look atAdding), and then the drop ends here and nothing is said. Either makeAcceptsDropfalse whilenfc.Adding(and raise it fromSetAdding), or put a line inReport/a toast such as "Still adding the last files: drop these again once it is done."@ -214,3 +227,4 @@| | ||---|---|| `LONGSHOT_NFC_DIR=<folder>` | The NFC folder somewhere else (a full path), for the game and the launcher alike ([docs/nfc.md](docs/nfc.md)) |Not true on Linux yet:
GamePlay.Environment(Core/MakeGameCommand.cs,Dropped="LONGSHOT_", …) removes this variable before the game starts, so there the launcher and the game read different folders. Either let it through (e.g.&& kv.Key != NfcTags.Variablebeside theDroppedtest, plus a check in the launcher core tests thatGamePlay.Environment(Platform.Linux, …)keeps it) or say here and in docs/nfc.md that it only reaches the game on Windows. Letting it through looks like the better fix, since the page is built on the two sharing one folder.@ -0,0 +15,4 @@|---|---|| Windows | `%LOCALAPPDATA%\Longshot\nfc` || Linux and Steam Deck | `$XDG_DATA_HOME/longshot/nfc` (default `~/.local/share/longshot/nfc`) || Either | `LONGSHOT_NFC_DIR=<folder>`, when it is set and not empty, instead |Same as the README: on Linux a game started by the launcher never sees
LONGSHOT_NFC_DIR(it is stripped with the otherLONGSHOT_*variables), so Either only holds on Windows today. This also applies to the relative-path paragraph below it.Pushed
77867988andc3a934cdon top of2644cdc0, for the points of the second review (the request for changes on2644cdc0) and to bring the branch up to date with main. main is merged in, not rebased; nothing was force-pushed.77867988). The PR no longer merged cleanly: main's #52 (Hookshot settings and the NX2navi import) added a line at the same three places as this branch, the dialogs' data templates inApp/MainWindow.axaml, the views inApp/Views/Views.csand the core checks' list intests/launcher_core/Program.cs. Each conflict kept both lines; nothing else needed a hand.LONGSHOT_NFC_DIRon Linux (must,c3a934cd). Let through, as suggested:GamePlay.EnvironmentkeepsNfcTags.Variablebeside theDroppedtest, so the game the launcher starts on Linux reads the same folder as the page; every otherLONGSHOT_*variable is still dropped. A new check inNfcChecks()(next to the folder checks) givesGamePlay.Environment(Platform.Linux, …)LONGSHOT_NFC_DIR, aLONGSHOT_NFC_DIRSandLONGSHOT_TOOLS: the first is kept, the other two dropped, and Windows keeps it too. With the change taken out, that check fails. The README's environment row and docs/nfc.md now say the launcher passes it on to the game on both systems (a short paragraph under the Either row), and the relative-path paragraph says the game is started in the build's folder on both.c3a934cd).MainViewModel.AcceptsDropis nowpage is FilesStepViewModel or NfcViewModel { Adding: false }, andSetAddingraises it (Main.RaiseAcceptsDrop()). While an add runs, the window'sDragsets the effect to None and hides the overlay, so the cursor shows "no drop" instead of a drop that ends silently. docs/nfc.md's Adding says so.Tested (Linux, .NET SDK 10.0.404), at
c3a934cd:dotnet build LongshotLauncher.slnx: 0 errors (Debug, and Release with-p:RestoreLockedMode=trueas CI). One warning,AVLN5001onBuildStepView.axaml'sWatermark, a file this PR doesn't touch.tests/test_launcher_core.py --strict --longshot <Longshot main at f87557ae>:launcher core: 929 checks passed. No failure, so nothing to compare against main.tests/test_release.py: 28 tests OK.Not tested: no window was opened, so the NFC page, drag and drop (including the refused drop while adding) and adding a big folder still need a run on Windows and Linux. CI on
c3a934cdis the next check.Re-review of the whole PR against main at
c3a934cd(mainc5440787merged in at77867988), built and run here on Linux.Resolved from the last review (the request for changes on
2644cdc0):LONGSHOT_NFC_DIRon Linux:GamePlay.EnvironmentkeepsNfcTags.Variableand still drops every otherLONGSHOT_*(LONGSHOT_NFC_DIRStoo: the test is an exact key, not a prefix). The new check inNfcChecks()covers Linux and Windows. The README row, docs/nfc.md's paragraph under Either and the relative-path paragraph now match the code.AcceptsDropis false whileAdding,SetAddingraises it, and the window'sDragreads it on everyDragOver, so the effect is None and the overlay hidden for the whole add. docs/nfc.md's Adding says so.MainWindow.axaml's dialog templates,Views.cs, the core checks' list inProgram.cs) each keep both lines, and the merge changes nothing else (jj diff -r 77867988shows only those three).The rest holds up: the files are only ever added through
Place(exists check, thenAtomicFile), deletes are limited to.bin/.nfcnames directly in the folder, the reader can't build0x08/0x14, and the controller's answers and the.bin/.nfcparsing are bounded (size checked before reading, 1 MB cap on.nfc, page numbers checked, buffer capped at 4 KB).Must change: adding a folder follows directory symlinks on Linux, so a symlink loop makes the walk effectively endless (inline on
FilesUnder).Nit: inline.
Tested (Linux, .NET SDK 10.0.404, at
c3a934cd):dotnet build LongshotLauncher.slnx0 errors (Debug, and Release with-p:RestoreLockedMode=trueas CI; the one warning isAVLN5001inBuildStepView.axaml, not this PR's).tests/test_launcher_core.py --strict --longshot <Longshot main at f87557a>:launcher core: 929 checks passed.tests/test_release.py: 28 OK. No window was opened.CI: on
c3a934cdonly "Conventional Commit title" ran (success). "Compile and test" is skipped on every pull request by design (ci.yml:if: github.event_name != 'pull_request'), so the runs above are the only build of this head.Description: "110 checks" and "NFC ONLY: 110 checks passed" are from
5c1c0366; there are more NFC checks now. Worth a word that those lines are from the first commit.@ -0,0 +202,4 @@public static IReadOnlyList<string> FilesUnder(string folder){if (!Directory.Exists(folder)) return Array.Empty<string>();var all = new EnumerationOptions { RecurseSubdirectories = true, IgnoreInaccessible = true, AttributesToSkip = FileAttributes.System };On Linux
RecurseSubdirectoriesfollows symlinks to folders. I checked with .NET 10 here: a folder with one..symlink is walked about 40 levels deep (untilELOOP), and with two such symlinks the walk grows as 2^depth and doesn't finish. That isn't exotic on Linux or a Steam Deck: every Wine/Proton prefix hasdosdevices/z: -> /, so Add a folder on the home folder or a drive (the case review 1 asked to keep responsive) never ends. The window stays responsive, butAddingstays on with no way to cancel (leaving the page doesn't stop it),ToList()keeps growing, and the page takes no more adds or drops.Smallest fix:
AttributesToSkip = FileAttributes.System | FileAttributes.ReparsePoint. I checked that this stops the loop on Linux (symlinks reportReparsePointthere). It also skips a symlinked.bin, which seems fine for a copy; otherwise set aMaxRecursionDepth. Please add a check with a loop of two symlinks to the parent folder, on Linux only.@ -0,0 +265,4 @@if (Same(target, file)) return (NfcTagOutcome.Same, name);continue;}AtomicFile.Write(target, file);Nit: the never-overwrite rule depends on the
File.Existsabove, andAtomicFile.Writethen moves withoverwrite: true. Today an overwrite needs two writers to choose the same name, and Scan a tag isn't turned off whileAdding. So a scan saved on the window's thread while an add runs inTask.Runcan, in theory, pick the sameScanned <UID>.bin. That's unlikely, but a move without overwrite (catchIOException, try the next number) would make the guarantee hold by construction.Pushed
921ac746on top ofc3a934cd, one commit for the points of the last review (#49 (comment)). Not rebased, nothing force-pushed.NfcTags.FilesUnderno longer usesRecurseSubdirectories. It walks the folders itself with a stack, and it doesn't go into a subfolder that is a link:ReparsePointand a non-nullLinkTarget, so a symlink, or a junction on Windows. I kept symlinked files rather than skipping every reparse point. Two reasons: a symlinked.binstill gets added as that file, and OneDrive's cloud-only folders are reparse points without aLinkTarget, soAttributesToSkip |= ReparsePointwould have skipped them on Windows. A new Linux-only check makes a folder with two links back up to it (inner/up -> ..andinner/up again -> <folder>) and a symlinked.bin. The walk has to finish within 20 s and give exactlyinner/deep.bin,linked.bin,top.bin. With the link test removed, the check fails ("the walk ends"). docs/nfc.md's Add a folder… says links to folders aren't followed and links to files are.AtomicFilehas a newWriteNew: the same write, butFile.Move(tmp, path, overwrite: false). It returns false when the name is taken by then, and the existing file is kept.Placeuses it: if a file appeared after theFile.Existscheck (a scan saved during an add), it's either the same bytes (already there) or the copy goes on to the next number.AtomicFile.Writeis unchanged for its other callers. A check:WriteNewover an existing file returns false and leaves its bytes, it works on a free name, and no.tmpis left behind. docs/nfc.md says the rename never replaces a file.921ac746(115 on Windows: two are Linux only)". The "NFC ONLY: 110 checks passed" line, the Windows build line and the author's folder-of-folders run are now marked as being from5c1c0366or before921ac746. The Linux run line now has this commit's numbers.Tested (Linux, .NET SDK 10.0.404), at
921ac746:dotnet build LongshotLauncher.slnx: 0 errors, Debug and Release with-p:RestoreLockedMode=true. The only warning is stillAVLN5001inBuildStepView.axaml.tests/test_launcher_core.py --strict --longshot <Longshot main at f87557ae>:launcher core: 932 checks passed. The NFC checks are 117 of them, counted with a counter in an uncommitted copy ofMain.tests/test_release.py: 28 tests OK.Not tested: no window was opened. The NFC page, drag and drop, and Add a folder on a real big folder (a home folder with a Proton prefix, a OneDrive folder on Windows) still need a run. The OneDrive point comes from how the Files On-Demand folders are marked, not from a run on Windows.
Re-review of
921ac746(the delta onc3a934cdand what it touches), built and run here on Linux.Resolved from the last review (#49 (comment)):
RecurseSubdirectories = false, a symlinked folder appears inEnumerateDirectorieswithDirectory, ReparsePointand aLinkTarget, and isn't pushed; the new check covers two links back up. A file symlink can't make the walk loop, because files are only listed, never gone into. A file link that loops on itself or is dangling is listed, then refused when it's read (Addcatches theIOException). The OneDrive reasoning holds: .NET'sLinkTargetis non-null only for symlink and mount-point (junction) reparse tags and null for the cloud-file tags, so junctions and directory symlinks are skipped and Files On-Demand folders are walked. I couldn't run that on Windows; it's from the API's behaviour.WriteNew: right on both systems.File.Move(..., overwrite: false)maps toMoveFileExwithoutMOVEFILE_REPLACE_EXISTINGon Windows, and on Linux .NET useslinkthenunlink, which fails withEEXISTatomically. Here a move onto an existing file throwsIOException, the target keeps its bytes and the source stays in place. Thefinallystill removes the temp file.Placethen reports already there or goes on to the next number, andWrite's other callers are unchanged.Must change: a symlinked
.binis listed but then refused, so "a link to a file is taken, as the file" (theFilesUndercomment, docs/nfc.md, the check's message, and the reason given for not skipping every reparse point) isn't true for.bin. Inline.Tested (Linux, .NET SDK 10.0.404, at
921ac746):dotnet build LongshotLauncher.slnx0 errors in Debug, and in Release with-p:RestoreLockedMode=trueas CI (onlyAVLN5001, as before).tests/test_launcher_core.py --strict --longshot <Longshot main at f87557a>:launcher core: 932 checks passed.tests/test_release.py: OK. I also ranNfcTags.Addon a symlinked.binin a scratch program (below). CI on921ac746: only the title check runs on pull requests (success); "Compile and test" is skipped by design.The description's testing section matches what I ran.
@ -0,0 +153,4 @@static byte[]? Bytes(string path, out string? problem){problem = null;var size = new FileInfo(path).Length;new FileInfo(path).Lengthis the link's own size, not its target's (lstat), so a symlinked.binfails the size test here. I tried it with .NET 10 on Linux:NfcTags.Add(nfc, ["src/linked.bin"]), wherelinked.bin -> src/real.bin(a valid 540-byte fake tag), givesRefused: it is 56 bytes, and a .bin dump is 532, 540 or 572, andListmarks it the same way. A.nfclink gets through, becauseReadAllBytesfollows it. On Windows a file symlink'sLengthis 0, so it's refused there too.The new check only tests that
FilesUnderlistslinked.bin, so it doesn't catch this. Either follow the link for the size (for examplevar info = new FileInfo(path); if (info.LinkTarget != null) info = (FileInfo?)info.ResolveLinkTarget(true) ?? info;, where a looping link throwsIOException, which the callers already catch), or read the bytes and test their length. Then extend the check toAddthe linked file and expectSame/Added. Or, if links aren't worth it, drop the claim from the comment, docs/nfc.md and the check.Pushed
4c77d3c6on top of921ac746, one commit for the last review (#49 (comment)). Not rebased, nothing force-pushed.A linked
.binwas refused (must).NfcTags.Bytesno longer looks atFileInfo.Length. It reads at most one byte past the largest a dump can be (573 bytes for a.bin, 1 MB plus one for a.nfc) through a newReadAtMost, which opens the file and so follows a link to the file it leads to. It then tests the length of what it read. So a linked.binis sized as its target, and the size cap still holds without reading a large file whole. It now also holds for a linked.nfc, which used to get past the 1 MB cap because the link's own size was tested. A.binlarger than any dump now says "it is more than 572 bytes, …", since only 573 bytes are read.Samecompares the same way, so a name taken by a link in the NFC folder is compared by what the link leads to. A link that loops or leads nowhere throwsIOExceptionwhen opened, andAdd/Listalready catch that.Checks. The Linux check with the two looping links now also passes what the walk found to
NfcTags.Addin a fresh folder. It expectsdeep.bin,linked.binandtop.binallAdded, withlinked.bina plain copy holding the target's bytes, not a link. With the old size test (FileInfo.Length) put back, it fails withRefused it is 75 bytes, …. A new check, on both systems, refuses a 600-byte.binas "more than 572 bytes". TheFilesUndercomment, docs/nfc.md ("a link to a file is taken as that file") and the check's messages are now true for.bintoo, so they are unchanged.Tested (Linux, .NET SDK 10.0.404), at
4c77d3c6:dotnet build LongshotLauncher.slnx: 0 errors, Debug and Release with-p:RestoreLockedMode=true. The only warning is stillAVLN5001inBuildStepView.axaml.tests/test_launcher_core.py --strict --longshot <Longshot main at f87557ae>:launcher core: 934 checks passed, 119 of them NFC checks (116 on Windows, where three are skipped).tests/test_release.py: 28 tests OK.Not tested: no window was opened, and nothing ran on Windows: a file symlink there (a
Lengthof 0) is covered by the same read, by reasoning only.Re-review of
4c77d3c6(the delta on921ac746), built and run here on Linux.Resolved from the last review (#49 (comment)): a linked
.binis now read through the link and added as a copy, and the extended loop check runsAddon it.ReadAtMostis right:min(16 KB, most + 1 - read), so it never reads pastmost + 1. A short read just loops, and EOF ends the loop.most + 1bytes, which the size test then refuses. A file that shrinks yields what is there.IOException(not found, a dangling or looping link) orUnauthorizedAccessException, andDescribeandAddalready catch both.Samereadingbytes.Length + 1makes a longer file unequal without reading all of it..bin, 1 MB + 1 for a.nfc.Nit: inline (a FIFO named
.bin); not blocking.Tested (Linux, .NET SDK 10.0.404, at
4c77d3c6):dotnet build LongshotLauncher.slnx0 errors in Debug, and in Release with-p:RestoreLockedMode=trueas CI (only the oldAVLN5001).tests/test_launcher_core.py --strict --longshot <Longshot main at f87557a>:launcher core: 934 checks passed.tests/test_release.py: 28 OK. CI on this head: the title check passed; "Compile and test" doesn't run on pull requests. Still not run by anyone: the page, drag and drop, and a big folder in a real window, as the description says.Approving: nothing blocking is left from any of the three reviews.
@ -0,0 +165,4 @@/// The file's first most + 1 bytes at most (through a link, to the file it leads to): more than most when it is largerstatic byte[] ReadAtMost(string path, int most){Nit: opening the file now happens before any size test, so a FIFO named
*.binblocks innew FileStreamuntil something writes to it. I checked:NfcTags.Liston a folder holdingmkfifo pipe.bindoesn't return. Before this commit a.binFIFO was refused on itsLengthof 0 (a.nfcone already blocked).ReloadrunsListon the window's thread, so a FIFO in the NFC folder would freeze the page as it opens. That's very unlikely (zips can't carry FIFOs), so this isn't blocking. If you want to close it: resolve the link (ResolveLinkTarget(true)) and skip anything that isn't a regular file before opening, or doListinTask.Runlike the adds.New commits pushed, approval review dismissed automatically according to repository settings
Merged main in (
7cde57e5), not rebased, nothing force-pushed. main's translations (#47) conflicted at two places: the drop overlay's text inApp/MainWindow.axaml(this branch's{Binding DropText}kept) and the README's table (both rows kept).MainViewModel.DropText's two texts now go throughTr.T, so the catalogs' "Drop your game file to check it" has its source again (scripts/translations.pysaid it was left over). The NFC page's own texts are not throughTr.T/{c:T}yet and are in no catalog: they show in English. I can do that here or in a follow-up, as you prefer. Built on Windows with warnings as errors;tests/test_launcher_core.pystill stops inSelfUpdateCheckson this PC, as main's does.The game's side of the 256 note (review 1185's should change, and #49 (comment)) is fixed in MagicBeanDev/Longshot#280 at 85d27e5e: the game now lists the first 256 tag files by name whatever order the folder gives them in, with a check that fails on the code before. It still counts every
.bin/.nfcthat is not akey_file, dumps or not, asTooManydoes. Once that pull request is in,TooManyText,NfcTags.Most's comment and docs/nfc.md can say "the first 256 by name" again; I have left them as they are until then, since they describe the game as merged.Please rebase!
7465d19d0eb51fa96f44Rebased onto main @
67d8410, as asked: the two merge commits are gone, and the branch is its five commits on main (headb51fa96). Conflicts:App/ViewModels/ViewModelBase.cs: main'sPickFileAsync(string title, string[]? patterns)kept, with this branch'sPickFilesAsyncbeside it.Core/MakeGameCommand.cs:Environmentkeeps main'sintelSideBySideandintelLongerLimits, and Linux still keepsLONGSHOT_NFC_DIR.Core/AtomicFile.cs: main's Windows mutex around the rename (#71), with this branch'soverwrite.App/MainWindow.axaml,App/Views/Views.cs,README.md,CONTRIBUTING.md,tests/launcher_core/Program.cs: both sides kept.7cde57ehad putDropText's two texts throughTr.T; that is now in the commit that addsDropText.Apart from that line, the branch's changes are the same as at
7465d19, compared line by line.Built with warnings as errors (SDK 10.0.404, as
global.jsonnow asks).tests/test_launcher_core.pypasses every check up toHomeBusySourceChecks, which stops on main too: #121 added&& !deletingLeftoverstoCanStartBuild, and the check still looks for the line without it.b51fa96f440414878272Rebased onto main @
bfa2448with no conflicts. It builds with-warnaserror, andtests/test_launcher_core.pypasses all 1469 checks (the HomeBusySourceChecks failure that main also had is fixed on main now).0414878272ced2f7c0afRebased onto main @
5d86f31with no conflicts. It builds with-warnaserror, andtests/test_launcher_core.pypasses all 1469 checks.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.