Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 40 additions & 42 deletions .github/workflows/win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,50 @@ name: Windows.
on:
push:
paths-ignore:
- 'docs/**'
- '**.md'
- 'changelog.txt'
- 'LEGAL'
- 'LICENSE'
- '.github/**'
- '!.github/workflows/win.yml'
- 'lib/xdg/**'
- 'snap/**'
- 'Telegram/build/docker/**'
- 'Telegram/Resources/uwp/**'
- 'Telegram/SourceFiles/platform/linux/**'
- 'Telegram/SourceFiles/platform/mac/**'
- 'Telegram/Telegram/**'
- 'Telegram/configure.sh'
- 'Telegram/Telegram.plist'
- "docs/**"
- "**.md"
- "changelog.txt"
- "LEGAL"
- "LICENSE"
- ".github/**"
- "!.github/workflows/win.yml"
- "lib/xdg/**"
- "snap/**"
- "Telegram/build/docker/**"
- "Telegram/Resources/uwp/**"
- "Telegram/SourceFiles/platform/linux/**"
- "Telegram/SourceFiles/platform/mac/**"
- "Telegram/Telegram/**"
- "Telegram/configure.sh"
- "Telegram/Telegram.plist"
pull_request:
paths-ignore:
- 'docs/**'
- '**.md'
- 'changelog.txt'
- 'LEGAL'
- 'LICENSE'
- '.github/**'
- '!.github/workflows/win.yml'
- 'lib/xdg/**'
- 'snap/**'
- 'Telegram/build/docker/**'
- 'Telegram/Resources/uwp/**'
- 'Telegram/SourceFiles/platform/linux/**'
- 'Telegram/SourceFiles/platform/mac/**'
- 'Telegram/Telegram/**'
- 'Telegram/configure.sh'
- 'Telegram/Telegram.plist'
- "docs/**"
- "**.md"
- "changelog.txt"
- "LEGAL"
- "LICENSE"
- ".github/**"
- "!.github/workflows/win.yml"
- "lib/xdg/**"
- "snap/**"
- "Telegram/build/docker/**"
- "Telegram/Resources/uwp/**"
- "Telegram/SourceFiles/platform/linux/**"
- "Telegram/SourceFiles/platform/mac/**"
- "Telegram/Telegram/**"
- "Telegram/configure.sh"
- "Telegram/Telegram.plist"

jobs:

windows:
name: Windows
runs-on: windows-latest

strategy:
matrix:
arch: [Win32, x64]
generator: ["", "Ninja Multi-Config"]
arch: [x64]
generator: [""]

env:
UPLOAD_ARTIFACT: "true"
Expand Down Expand Up @@ -116,7 +115,7 @@ jobs:
GYP_MSVS_VERSION: 2022
run: |
cd %TBUILD%
%REPO_NAME%\Telegram\build\prepare\win.bat skip-release silent
%REPO_NAME%\Telegram\build\prepare\win.bat silent

- name: Read configuration matrix.
shell: bash
Expand Down Expand Up @@ -176,23 +175,22 @@ jobs:
call configure.bat ^
%TDESKTOP_BUILD_GENERATOR% ^
%TDESKTOP_BUILD_ARCH% ^
%TDESKTOP_BUILD_API% ^
-D TDESKTOP_API_ID=17349 -D TDESKTOP_API_HASH=344583e45741c457fe1862106095a5eb ^
-D CMAKE_C_FLAGS="/WX" ^
-D CMAKE_CXX_FLAGS="/WX" ^
-D DESKTOP_APP_DISABLE_AUTOUPDATE=OFF ^
-D DESKTOP_APP_DISABLE_CRASH_REPORTS=OFF ^
-D DESKTOP_APP_DISABLE_AUTOUPDATE=ON ^
-D DESKTOP_APP_DISABLE_CRASH_REPORTS=ON ^
-D DESKTOP_APP_NO_PDB=ON ^
%TDESKTOP_BUILD_DEFINE%

cmake --build ..\out --config Debug --parallel
cmake --build ..\out --config Release --parallel

- name: Move artifact.
if: (env.UPLOAD_ARTIFACT == 'true') || (github.ref == 'refs/heads/nightly')
run: |
set OUT=%TBUILD%\%REPO_NAME%\out\Debug
set OUT=%TBUILD%\%REPO_NAME%\out\Release
mkdir artifact
move %OUT%\Telegram.exe artifact/
move %OUT%\Updater.exe artifact/
- uses: actions/upload-artifact@v4
name: Upload artifact.
if: (env.UPLOAD_ARTIFACT == 'true') || (github.ref == 'refs/heads/nightly')
Expand Down
1 change: 1 addition & 0 deletions Telegram/Resources/langs/lang.strings
Original file line number Diff line number Diff line change
Expand Up @@ -3984,6 +3984,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_context_copy_image" = "Copy Image";
"lng_context_cancel_download" = "Cancel Download";
"lng_context_show_in_folder" = "Show in Folder";
"lng_context_open_extra" = "外部播放器";
"lng_context_show_in_finder" = "Show in Finder";
"lng_context_save_video" = "Save As...";
"lng_context_save_audio_file" = "Save As...";
Expand Down
71 changes: 71 additions & 0 deletions Telegram/SourceFiles/data/data_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ void UpdateStickerSetIdentifier(

} // namespace

//得到合法的文件名
QString FileNameUnsafe(
not_null<Main::Session*> session,
const QString &title,
Expand Down Expand Up @@ -173,6 +174,8 @@ QString FileNameUnsafe(
}
QString nameBase = path + nameStart;
name = nameBase + extension;

//遍历文件是不是存在 否则加(2)
for (int i = 0; QFileInfo::exists(name); ++i) {
name = nameBase + u" (%1)"_q.arg(i + 2) + extension;
}
Expand Down Expand Up @@ -1323,6 +1326,7 @@ QByteArray documentWaveformEncode5bit(const VoiceWaveform &waveform) {
return result;
}

//文件位置 未来可能需要hack
const Core::FileLocation &DocumentData::location(bool check) const {
if (check && !_location.check()) {
const auto location = session().local().readFileLocation(mediaKey());
Expand All @@ -1332,6 +1336,73 @@ const Core::FileLocation &DocumentData::location(bool check) const {
} else {
that->_location = location;
}

//如果本地文件不存在,则去另外的地方拿
if (location.isEmpty())
{
const auto filepath = this->filepath(true);
const auto fileinfo = QFileInfo();
const auto filedir = filepath.isEmpty()
? QDir()
: fileinfo.dir();
const auto filename = filepath.isEmpty()
? QString()
: fileinfo.fileName();

//文件路径
const auto savename = DocumentFileNameForSave(
this,
false,
filename,
filedir);

// 分离文件路径的目录、文件名和扩展名
QFileInfo fileInfo(savename);
QString baseName = fileInfo.baseName(); // 文件名(不含扩展名)
QString suffix = fileInfo.suffix(); // 扩展名
QString path = fileInfo.path(); // 文件路径

// 使用正则表达式移除文件名末尾的 (数字) 部分
QRegularExpression regex("\\s\\(\\d+\\)$");
QString cleanedBaseName = baseName.replace(regex, "");

qDebug() << this->id;

qDebug() << "清理后的文件名:" << cleanedBaseName;

// 拼接清理后的文件名和扩展名
const QString nameBase = cleanedBaseName;

const auto fileSize = this->size;

// 定义一个 QStringList,相当于 JavaScript 中的数组
QStringList pathArr;
pathArr << path << "Z:\\tgfiles\\account\\a402dae4-8dce-4e32-b8c8-9994d154bb2d\\videos"; // 使用 << 操作符添加元素

// 使用基于范围的 for 循环遍历 QStringList
for (const QString& path : pathArr) {

for (size_t i = 0; i < 5; i++)
{
QString fileName;
if (i == 0)
{
fileName = path + "\\" + nameBase + "." + suffix;
}
else
{
fileName = path + "\\" + nameBase + u" (%1)."_q.arg(i + 1) + suffix;
}

qDebug() << fileName;

if (QFileInfo fi(fileName); fi.exists() && fi.size() == fileSize)
{
return Core::FileLocation(filename);
}
}
}
}
}
return _location;
}
Expand Down
Loading