Skip to content

Usenet streaming with a WebDAV server and a SABnzbd-compatible API

C#

Ensure `/completed-symlinks` files point to `/.ids` directory.

nzbdav-dev710472bf4b44
diff --git a/backend/WebDav/DatabaseStoreIdsCollection.cs b/backend/WebDav/DatabaseStoreIdsCollection.cs
index 34de503e..79628cc3 100644
--- a/backend/WebDav/DatabaseStoreIdsCollection.cs
+++ b/backend/WebDav/DatabaseStoreIdsCollection.cs
@@ -22,7 +22,7 @@ public class DatabaseStoreIdsCollection(
public override string UniqueKey => currentPath;
public override DateTime CreatedAt => default;
- private const int FanningDepth = 5;
+ public const int FanningDepth = 5;
private const string Alphabet = "0123456789abcdef";
private readonly string[] _currentPathParts = currentPath.Split(
diff --git a/backend/WebDav/DatabaseStoreSymlinkFile.cs b/backend/WebDav/DatabaseStoreSymlinkFile.cs
index cc266dd4..a0ea5de6 100644
--- a/backend/WebDav/DatabaseStoreSymlinkFile.cs
+++ b/backend/WebDav/DatabaseStoreSymlinkFile.cs
@@ -16,11 +16,7 @@ public class DatabaseStoreSymlinkFile(DavItem davFile, string parentPath, Config
public override long FileSize => ContentBytes.Length;
public override DateTime CreatedAt => davFile.CreatedAt;
- private string TargetPath =>
- Path.Combine(configManager.GetRcloneMountDir(), DavItem.ContentFolder.Name, parentPath, davFile.Name);
-
- private byte[] ContentBytes =>
- Encoding.UTF8.GetBytes(TargetPath);
+ private byte[] ContentBytes => Encoding.UTF8.GetBytes(GetTargetPath());
public override Task<Stream> GetReadableStreamAsync(CancellationToken cancellationToken)
{
@@ -38,4 +34,16 @@ public class DatabaseStoreSymlinkFile(DavItem davFile, string parentPath, Config
Log.Error("symlinks files cannot be copied. They simply mirror items in the /content root");
return Task.FromResult(new StoreItemResult(DavStatusCode.Forbidden));
}
+
+ private string GetTargetPath()
+ {
+ var pathParts = davFile.Id.ToString()
+ .Select(x => x.ToString())
+ .Take(DatabaseStoreIdsCollection.FanningDepth)
+ .Prepend(DavItem.IdsFolder.Name)
+ .Prepend(configManager.GetRcloneMountDir())
+ .Append(davFile.Id.ToString())
+ .ToArray();
+ return Path.Join(pathParts);
+ }
}
\ No newline at end of file