{"record":{"id":"d7ae70e0e3471581","repo":"duplicati/duplicati","slug":"usage-dotnet-run-path-to-source-folder-copyri","errorCode":null,"errorMessage":"Usage: dotnet run <path-to-source-folder> [\"copyright name\"]","messagePattern":"Usage: dotnet run <path-to-source-folder> \\[\"copyright name\"\\]","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"BuildTools/LicenseUpdater/Program.cs","lineNumber":26,"sourceCode":"// and/or sell copies of the Software, and to permit persons to whom the \r\n// Software is furnished to do so, subject to the following conditions:\r\n// \r\n// The above copyright notice and this permission notice shall be included in \r\n// all copies or substantial portions of the Software.\r\n// \r\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS \r\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \r\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE \r\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \r\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING \r\n// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER \r\n// DEALINGS IN THE SOFTWARE.\r\n\r\nusing LicenseUpdater;\r\n\r\nvar cmdargs = Environment.GetCommandLineArgs();\r\nif (cmdargs.Length != 2 && cmdargs.Length != 3)\r\n    throw new Exception($\"Usage: dotnet run <path-to-source-folder> [\\\"copyright name\\\"]\");\r\n\r\nif (cmdargs.Length == 3)\r\n    Fragments.CopyrightHolder = cmdargs[2];\r\n\r\nvar startpath = Path.GetFullPath(Environment.GetCommandLineArgs().Skip(1).First());\r\nif (!Directory.Exists(startpath))\r\n    throw new Exception($\"Start path not found: {startpath}\");\r\n\r\nvar target_extensions = new[] {\r\n    \".cs\",\r\n    \".csproj\"\r\n    // \".html\",\r\n    // \".js\",\r\n    // \".css\"\r\n}.ToHashSet(StringComparer.OrdinalIgnoreCase);\r\n\r\nFile.WriteAllText(Path.Combine(startpath, \"LICENSE\"), Fragments.LICENSE_FILE_HEADER + Fragments.GetLicenseTextWithPrefixedLines(string.Empty));\r\n\r","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/duplicati/duplicati/blob/3f348be3e33f5d72d414e3ad55839c2ba34dda67/BuildTools/LicenseUpdater/Program.cs#L8-L44","documentation":"Thrown by LinkFilesetToVolumeAsync when the UPDATE that sets Fileset.VolumeID returns a row count other than 1. The SQL updates exactly the Fileset row matching ID = @FilesetId; a result of 0 means the fileset ID does not exist, and any other count would imply a schema problem (duplicate primary key). This is a plain System.Exception (not DatabaseInconsistencyException), indicating an unexpected internal state.","triggerScenarios":"LinkFilesetToVolumeAsync is called with a (filesetid, volumeid) pair. It runs UPDATE Fileset SET VolumeID = @VolumeId WHERE ID = @FilesetId within transaction m_rtr and checks that exactly 1 row was affected. If filesetid was already deleted, never created, or the caller passed a stale ID, the count is 0 and the exception fires.","commonSituations":"Called during fileset-to-volume linking after uploading a new backup version or during repair. A stale or invalid filesetid -- e.g., referencing a fileset that a concurrent delete operation already removed -- is the most common cause. Can also occur if the fileset was created in a different transaction that was rolled back.","solutions":["Verify that filesetid exists in the Fileset table before calling LinkFilesetToVolumeAsync by running SELECT COUNT(*) FROM Fileset WHERE ID = @FilesetId.","Ensure the calling code holds the correct transaction (m_rtr) and that the fileset row was committed in the same or a prior committed transaction.","Check for concurrent delete operations that might have removed the fileset between creation and linking.","Run the Duplicati repair command to rebuild the database if the fileset table is in an inconsistent state."],"exampleFix":"// before\nawait db.LinkFilesetToVolumeAsync(filesetid, volumeid, token);\n// after\nvar exists = await db.ExecuteScalarInt64Async(\n    \"SELECT COUNT(*) FROM \\\"Fileset\\\" WHERE \\\"ID\\\" = @Id\", token);\nif (exists == 1)\n    await db.LinkFilesetToVolumeAsync(filesetid, volumeid, token);\nelse\n    throw new InvalidOperationException($\"Fileset {filesetid} does not exist; cannot link to volume {volumeid}\");","handlingStrategy":"validation","validationCode":"// Pre-check: fileset exists before linking\nlong count = await db.ExecuteScalarInt64Async(\n    \"SELECT COUNT(*) FROM \\\"Fileset\\\" WHERE \\\"ID\\\" = @Id\", token);\nif (count != 1)\n    throw new InvalidOperationException($\"Fileset {filesetid} not found\");\nawait db.LinkFilesetToVolumeAsync(filesetid, volumeid, token);","typeGuard":"// N/A -- SQL row-count assertion, not a type issue","tryCatchPattern":"try {\n    await db.LinkFilesetToVolumeAsync(filesetid, volumeid, token);\n} catch (Exception ex) when (ex.Message.Contains(\"Failed to link filesetid\")) {\n    logger.LogError(\"Cannot link fileset {FilesetId} to volume {VolumeId}; fileset may be stale\", filesetid, volumeid);\n    throw;\n}","preventionTips":["Ensure the fileset row is committed in a prior transaction before calling LinkFilesetToVolumeAsync.","Avoid concurrent delete operations that might remove the fileset between creation and linking.","Pass only freshly created fileset IDs obtained from the same database connection context."],"tags":["duplicati","database","sqlite","transaction","fileset","volume-linking"],"backgroundTag":null,"analyzedSha":"3f348be3e33f5d72d414e3ad55839c2ba34dda67","analyzedAt":"2026-08-13T16:48:27.008Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}