Skip to content

Commit c7418e4

Browse files
committed
feat: bump .net to 10
1 parent a4a7c10 commit c7418e4

7 files changed

Lines changed: 70 additions & 30 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ services:
3838
api_id: ""
3939
hash_id: ""
4040
DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE: false
41+
DOTNET_CLI_TELEMETRY_OPTOUT: true
4142
restart: unless-stopped
4243
depends_on:
4344
- mongodb_container

TelegramDownloader/Dockerfile

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
22

3-
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
3+
# Alpine base image (~110MB vs ~220MB Debian)
4+
FROM mcr.microsoft.com/dotnet/aspnet:10.0-alpine AS base
45
WORKDIR /app
56
EXPOSE 80
67
EXPOSE 443
78

8-
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
9+
FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS build
910
ARG BUILD_CONFIGURATION=Release
1011
WORKDIR /src
1112
COPY ["TelegramDownloader.csproj", "."]
1213
RUN dotnet restore "TelegramDownloader.csproj"
1314
COPY . .
14-
RUN echo $(ls -1 ./)
1515
WORKDIR "/src/."
1616
RUN dotnet build "./TelegramDownloader.csproj" -c $BUILD_CONFIGURATION -o /app/build
1717

@@ -22,24 +22,19 @@ RUN dotnet publish "./TelegramDownloader.csproj" -c $BUILD_CONFIGURATION -o /app
2222
FROM base AS final
2323
WORKDIR /app
2424

25-
# Instala Python y pip
26-
RUN apt-get update && \
27-
apt-get install -y python3 python3-pip python3-venv && \
28-
ln -s /usr/bin/python3 /usr/bin/python && \
29-
rm -rf /var/lib/apt/lists/*
25+
# Install Python (Alpine uses apk instead of apt)
26+
RUN apk add --no-cache python3 py3-pip && \
27+
ln -sf /usr/bin/python3 /usr/bin/python
3028

3129
COPY ./WebDav /app/WebDav
32-
RUN python3 -m venv /app/venv
3330

34-
# Añade el venv al PATH para que "python" y los scripts (uvicorn, etc.) estén disponibles globalmente
35-
ENV PATH="/app/venv/bin:${PATH}"
36-
37-
# Actualiza pip e instala requirements dentro del venv
38-
RUN python -m pip install --upgrade pip
39-
RUN python -m pip install -r /app/WebDav/requirements.txt
31+
# Create venv and install dependencies in single layer
32+
RUN python3 -m venv /app/venv && \
33+
/app/venv/bin/pip install --no-cache-dir --upgrade pip && \
34+
/app/venv/bin/pip install --no-cache-dir -r /app/WebDav/requirements.txt && \
35+
/app/venv/bin/python -c "import uvicorn; print('uvicorn OK', uvicorn.__version__)"
4036

41-
# Comprobación opcional para fallar la build si falta uvicorn
42-
RUN python -c "import uvicorn; print('uvicorn OK', uvicorn.__version__)"
37+
ENV PATH="/app/venv/bin:${PATH}"
4338

4439
COPY --from=publish /app/publish .
4540
ENTRYPOINT ["dotnet", "TelegramDownloader.dll"]

TelegramDownloader/Pages/Index.razor

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@page "/"
33
@implements IDisposable
44

5+
@using Microsoft.AspNetCore.Components
56
@using QRCoder
67
@using TelegramDownloader.Data
78
@using TelegramDownloader.Models
@@ -108,12 +109,17 @@
108109

109110
protected override async Task OnInitializedAsync()
110111
{
111-
Model ??= new();
112-
Model.type = await ts.checkAuth(Model.value);
113-
StateHasChanged();
114-
await isLogin();
115-
116-
112+
try
113+
{
114+
Model ??= new();
115+
Model.type = await ts.checkAuth(Model.value);
116+
StateHasChanged();
117+
await isLogin();
118+
}
119+
catch (NavigationException)
120+
{
121+
// Expected when navigating during initialization in Blazor Server
122+
}
117123
}
118124

119125

TelegramDownloader/Shared/MobileFileManager/MobileFileManager.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
{
131131
<MobileFileItem
132132
File="file"
133-
IsSelected="@SelectedItems.Contains(file)"
133+
IsSelected="@IsItemSelected(file)"
134134
ViewMode="@ViewMode"
135135
OnClick="() => OnFileClick(file)"
136136
OnLongPress="() => OnFileLongPress(file)"

TelegramDownloader/Shared/MobileFileManager/MobileFileManager.razor.cs

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,26 @@ public partial class MobileFileManager : ComponentBase
126126
private bool SortAscending { get; set; } = true;
127127

128128
private List<FileManagerDirectoryContent> Files { get; set; } = new();
129-
private List<FileManagerDirectoryContent> DisplayFiles => GetDisplayFiles();
129+
130+
// Cached display files - invalidated when data/filters change
131+
private List<FileManagerDirectoryContent>? _cachedDisplayFiles;
132+
private bool _displayFilesDirty = true;
133+
private List<FileManagerDirectoryContent> DisplayFiles
134+
{
135+
get
136+
{
137+
if (_displayFilesDirty || _cachedDisplayFiles == null)
138+
{
139+
_cachedDisplayFiles = GetDisplayFiles();
140+
_displayFilesDirty = false;
141+
}
142+
return _cachedDisplayFiles;
143+
}
144+
}
145+
130146
private List<FileManagerDirectoryContent> PagedFiles => GetPagedFiles();
131147
private List<FileManagerDirectoryContent> SelectedItems { get; set; } = new();
148+
private HashSet<string> _selectedIds = new(); // O(1) lookup for selection state
132149
private List<FileManagerDirectoryContent> ClipboardItems { get; set; } = new();
133150
private bool IsCutOperation { get; set; } = false;
134151

@@ -223,6 +240,7 @@ private async Task LoadFiles()
223240
f.FilterPath = NormalizePath(f.FilterPath);
224241
return f;
225242
}).ToList();
243+
InvalidateDisplayFilesCache();
226244
}
227245

228246
if (args.Response?.CWD != null)
@@ -246,6 +264,16 @@ public async Task RefreshFilesAsync()
246264
await LoadFiles();
247265
}
248266

267+
private void InvalidateDisplayFilesCache()
268+
{
269+
_displayFilesDirty = true;
270+
}
271+
272+
private bool IsItemSelected(FileManagerDirectoryContent file)
273+
{
274+
return _selectedIds.Contains(file.Id);
275+
}
276+
249277
private List<FileManagerDirectoryContent> GetDisplayFiles()
250278
{
251279
var files = Files ?? new List<FileManagerDirectoryContent>();
@@ -451,31 +479,35 @@ private void OnFileLongPress(FileManagerDirectoryContent file)
451479

452480
private void ToggleSelection(FileManagerDirectoryContent file)
453481
{
454-
if (SelectedItems.Contains(file))
482+
if (_selectedIds.Contains(file.Id))
455483
{
456484
SelectedItems.Remove(file);
485+
_selectedIds.Remove(file.Id);
457486
}
458487
else
459488
{
460489
SelectedItems.Add(file);
490+
_selectedIds.Add(file.Id);
461491
}
462492

463-
OnSelectedItemsChanged.InvokeAsync(SelectedItems.Select(f => f.Id).ToArray());
493+
OnSelectedItemsChanged.InvokeAsync(_selectedIds.ToArray());
464494
StateHasChanged();
465495
}
466496

467497
private void ClearSelection()
468498
{
469499
SelectedItems.Clear();
500+
_selectedIds.Clear();
470501
OnSelectedItemsChanged.InvokeAsync(Array.Empty<string>());
471502
StateHasChanged();
472503
}
473504

474505
private void SelectAll()
475506
{
476507
SelectedItems = new List<FileManagerDirectoryContent>(DisplayFiles);
508+
_selectedIds = new HashSet<string>(SelectedItems.Select(f => f.Id));
477509
ShowMoreMenu = false;
478-
OnSelectedItemsChanged.InvokeAsync(SelectedItems.Select(f => f.Id).ToArray());
510+
OnSelectedItemsChanged.InvokeAsync(_selectedIds.ToArray());
479511
StateHasChanged();
480512
}
481513

@@ -969,6 +1001,7 @@ await InvokeAsync(async () =>
9691001
f.FilterPath = NormalizePath(f.FilterPath);
9701002
return f;
9711003
}).ToList();
1004+
InvalidateDisplayFilesCache();
9721005
}
9731006
}
9741007
else
@@ -1032,13 +1065,15 @@ private void SortFiles()
10321065
"Type" => "Name",
10331066
_ => "Name"
10341067
};
1068+
InvalidateDisplayFilesCache();
10351069
ResetPagination();
10361070
StateHasChanged();
10371071
}
10381072

10391073
private void ToggleSortDirection()
10401074
{
10411075
SortAscending = !SortAscending;
1076+
InvalidateDisplayFilesCache();
10421077
ResetPagination();
10431078
StateHasChanged();
10441079
}
@@ -1088,20 +1123,23 @@ private void ToggleTypeFilter(string type)
10881123
{
10891124
SelectedTypeFilters.Add(type);
10901125
}
1126+
InvalidateDisplayFilesCache();
10911127
ResetPagination();
10921128
StateHasChanged();
10931129
}
10941130

10951131
private void SelectAllTypeFilters()
10961132
{
10971133
SelectedTypeFilters = new HashSet<string>(AvailableFileTypes);
1134+
InvalidateDisplayFilesCache();
10981135
ResetPagination();
10991136
StateHasChanged();
11001137
}
11011138

11021139
private void ClearTypeFilters()
11031140
{
11041141
SelectedTypeFilters.Clear();
1142+
InvalidateDisplayFilesCache();
11051143
ResetPagination();
11061144
StateHasChanged();
11071145
}

TelegramDownloader/TelegramDownloader.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Version>0.0.0.0</Version>
55
<Authors>Mateo</Authors>
66
<Product>TelegramFileManager</Product>
7-
<TargetFramework>net8.0</TargetFramework>
7+
<TargetFramework>net10.0</TargetFramework>
88
<Nullable>enable</Nullable>
99
<ImplicitUsings>enable</ImplicitUsings>
1010
<UserSecretsId>528ba20b-8482-4c0f-9c2f-7ecc8dc30410</UserSecretsId>

Test/Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77

0 commit comments

Comments
 (0)