Merged Cake and Abel branched into 2.0.3 (#131)
Co-authored-by: azyges <aaaaaa@aaa.aaa> Co-authored-by: cake <admin@cakeandbanana.nl> Co-authored-by: defnotken <itsdefnotken@gmail.com> Reviewed-on: #131
This commit was merged in pull request #131.
This commit is contained in:
@@ -6,5 +6,6 @@ public enum DownloadStatus
|
||||
WaitingForSlot,
|
||||
WaitingForQueue,
|
||||
Downloading,
|
||||
Decompressing
|
||||
Decompressing,
|
||||
Completed
|
||||
}
|
||||
@@ -1,10 +1,46 @@
|
||||
namespace LightlessSync.WebAPI.Files.Models;
|
||||
using System.Threading;
|
||||
|
||||
namespace LightlessSync.WebAPI.Files.Models;
|
||||
|
||||
public class FileDownloadStatus
|
||||
{
|
||||
public DownloadStatus DownloadStatus { get; set; }
|
||||
public long TotalBytes { get; set; }
|
||||
public int TotalFiles { get; set; }
|
||||
public long TransferredBytes { get; set; }
|
||||
public int TransferredFiles { get; set; }
|
||||
}
|
||||
private int _downloadStatus;
|
||||
private long _totalBytes;
|
||||
private int _totalFiles;
|
||||
private long _transferredBytes;
|
||||
private int _transferredFiles;
|
||||
|
||||
public DownloadStatus DownloadStatus
|
||||
{
|
||||
get => (DownloadStatus)Volatile.Read(ref _downloadStatus);
|
||||
set => Volatile.Write(ref _downloadStatus, (int)value);
|
||||
}
|
||||
|
||||
public long TotalBytes
|
||||
{
|
||||
get => Interlocked.Read(ref _totalBytes);
|
||||
set => Interlocked.Exchange(ref _totalBytes, value);
|
||||
}
|
||||
|
||||
public int TotalFiles
|
||||
{
|
||||
get => Volatile.Read(ref _totalFiles);
|
||||
set => Volatile.Write(ref _totalFiles, value);
|
||||
}
|
||||
|
||||
public long TransferredBytes
|
||||
{
|
||||
get => Interlocked.Read(ref _transferredBytes);
|
||||
set => Interlocked.Exchange(ref _transferredBytes, value);
|
||||
}
|
||||
|
||||
public int TransferredFiles
|
||||
{
|
||||
get => Volatile.Read(ref _transferredFiles);
|
||||
set => Volatile.Write(ref _transferredFiles, value);
|
||||
}
|
||||
|
||||
public void AddTransferredBytes(long delta) => Interlocked.Add(ref _transferredBytes, delta);
|
||||
|
||||
public void SetTransferredFiles(int files) => Volatile.Write(ref _transferredFiles, files);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user