Skip to content

Commit

Permalink
Fix: Fixed an issue where installation errors occurred in some cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
X1a0He committed Nov 6, 2024
1 parent e6fe59a commit 51c19c8
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 76 deletions.
1 change: 1 addition & 0 deletions Adobe Downloader/Adobe DownloaderApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import SwiftUI

@main
struct Adobe_DownloaderApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@StateObject private var networkManager = NetworkManager()
@State private var showBackupAlert = false
@State private var showTipsSheet = false
Expand Down
8 changes: 8 additions & 0 deletions Adobe Downloader/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Cocoa
import SwiftUI

class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ notification: Notification) {
NSApp.mainMenu = nil
}
}
2 changes: 0 additions & 2 deletions Adobe Downloader/Commons/Structs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,4 @@ struct NetworkConstants {
static let downloadHeaders = [
"User-Agent": "Creative Cloud"
]

static let MAC_VOLUME_ICON_PATH = "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/CDAudioVolumeIcon.icns"
}
10 changes: 8 additions & 2 deletions Adobe Downloader/NetworkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ class NetworkManager: ObservableObject {
@Published var loadingState: LoadingState = .idle
@Published var downloadTasks: [NewDownloadTask] = []
@Published var installationState: InstallationState = .idle
@Published var installationLogs: [String] = []
@Published var installationLogs: [String] = [] {
didSet {
if installationLogs.count > 1000 {
installationLogs = Array(installationLogs.suffix(1000))
}
}
}
private let cancelTracker = CancelTracker()
internal var downloadUtils: DownloadUtils!
internal var progressObservers: [UUID: NSKeyValueObservation] = [:]
Expand Down Expand Up @@ -295,7 +301,7 @@ class NetworkManager: ObservableObject {
URLQueryItem(name: "_type", value: "xml"),
URLQueryItem(name: "channel", value: "ccm"),
URLQueryItem(name: "channel", value: "sti"),
URLQueryItem(name: "platform", value: allowedPlatform.joined(separator: ",")),
URLQueryItem(name: "platform", value: "osx10-64,osx10,macarm64,macuniversal"),
URLQueryItem(name: "productType", value: "Desktop")
]

Expand Down
24 changes: 20 additions & 4 deletions Adobe Downloader/Utils/DownloadUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class DownloadUtils {
<Dependency>
<SAPCode>\(dependency.sapCode)</SAPCode>
<BaseVersion>\(dependency.version)</BaseVersion>
<EsdDirectory>./\(dependency.sapCode)</EsdDirectory>
<EsdDirectory>\(dependency.sapCode)</EsdDirectory>
</Dependency>
"""
}.joined(separator: "\n")
Expand All @@ -181,7 +181,7 @@ class DownloadUtils {
<SAPCode>\(sapCode)</SAPCode>
<CodexVersion>\(version)</CodexVersion>
<Platform>\(productInfo.apPlatform)</Platform>
<EsdDirectory>./\(sapCode)</EsdDirectory>
<EsdDirectory>\(sapCode)</EsdDirectory>
<Dependencies>
\(dependencies)
</Dependencies>
Expand Down Expand Up @@ -271,6 +271,22 @@ class DownloadUtils {
}
}

for product in task.productsToDownload {
let productDir = task.directory.appendingPathComponent(product.sapCode)
if !FileManager.default.fileExists(atPath: productDir.path) {
do {
try FileManager.default.createDirectory(
at: productDir,
withIntermediateDirectories: true,
attributes: nil
)
} catch {
print("Error creating directory for \(product.sapCode): \(error)")
continue
}
}
}

for product in task.productsToDownload {
for package in product.packages where !package.downloaded {
let currentIndex = await progress.get()
Expand Down Expand Up @@ -332,7 +348,7 @@ class DownloadUtils {

return try await withCheckedThrowingContinuation { continuation in
let delegate = DownloadDelegate(
destinationDirectory: task.directory.appendingPathComponent("Contents/Resources/products/\(product.sapCode)"),
destinationDirectory: task.directory.appendingPathComponent(product.sapCode),
fileName: package.fullPackageName,
completionHandler: { [weak networkManager] localURL, response, error in
if let error = error {
Expand Down Expand Up @@ -810,7 +826,7 @@ class DownloadUtils {

if let currentPackage = task.currentPackage {
let destinationDir = task.directory
.appendingPathComponent("Contents/Resources/products/\(task.sapCode)")
.appendingPathComponent("\(task.sapCode)")
let fileURL = destinationDir.appendingPathComponent(currentPackage.fullPackageName)
try? FileManager.default.removeItem(at: fileURL)
}
Expand Down
9 changes: 9 additions & 0 deletions Adobe Downloader/Utils/InstallManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
//
// Created by X1a0He on 2024/10/30.
//
/*
Adobe Exit Code
107: 架构或者版本不一致
103: 权限问题
182: 可能是文件不全或者出错了
*/
import Foundation

actor InstallManager {
Expand Down Expand Up @@ -49,6 +55,9 @@ actor InstallManager {
installProcess.arguments = ["--install=1", "--driverXML=\(driverPath)"]
}

let commandString = "sudo \"\(setupPath)\" --install=1 --driverXML=\"\(driverPath)\""
print(commandString)

let outputPipe = Pipe()
installProcess.standardOutput = outputPipe
installProcess.standardError = outputPipe
Expand Down
64 changes: 8 additions & 56 deletions Adobe Downloader/Views/InstallProgressView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,16 @@ private struct LogSection: View {

var body: some View {
ScrollViewReader { proxy in
ScrollView(showsIndicators: false) {
VStack(alignment: .leading, spacing: 2) {
ForEach(Array(logs.enumerated()), id: \.offset) { index, log in
ScrollView(showsIndicators: true) {
LazyVStack(alignment: .leading, spacing: 2) {
ForEach(Array(logs.suffix(1000).enumerated()), id: \.offset) { index, log in
Text(log)
.font(.system(.caption, design: .monospaced))
.foregroundColor(.secondary)
.id(index)
.padding(.horizontal, 8)
.padding(.vertical, 2)
.textSelection(.enabled)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
Expand All @@ -142,8 +143,10 @@ private struct LogSection: View {
)
.padding(.horizontal, 20)
.onChange(of: logs) { _, newValue in
withAnimation {
proxy.scrollTo(newValue.count - 1, anchor: .bottom)
if !newValue.isEmpty {
withAnimation {
proxy.scrollTo(newValue.count - 1, anchor: .bottom)
}
}
}
}
Expand Down Expand Up @@ -217,57 +220,6 @@ private struct ButtonSection: View {
}
}

#Preview("安装中") {
InstallProgressView(
productName: "Adobe Photoshop",
progress: 0.45,
status: "正在安装核心组件...",
onCancel: {},
onRetry: nil
)
}

#Preview("准备安装") {
InstallProgressView(
productName: "Adobe Photoshop",
progress: 0.0,
status: "正在准备安装...",
onCancel: {},
onRetry: nil
)
}

#Preview("安装完成") {
InstallProgressView(
productName: "Adobe Photoshop",
progress: 1.0,
status: "安装完成",
onCancel: {},
onRetry: nil
)
}

#Preview("安装失败") {
InstallProgressView(
productName: "Adobe Photoshop",
progress: 0.0,
status: "安装失败: 权限被拒绝",
onCancel: {},
onRetry: {}
)
}

#Preview("在深色模式下") {
InstallProgressView(
productName: "Adobe Photoshop",
progress: 0.75,
status: "正在安装...",
onCancel: {},
onRetry: nil
)
.preferredColorScheme(.dark)
}

#Preview("安装中带日志") {
let networkManager = NetworkManager()
return InstallProgressView(
Expand Down
Binary file removed imgs/1024pt-1.png
Binary file not shown.
Binary file modified imgs/Adobe Downloader.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified imgs/download.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified imgs/language.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified imgs/preview-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified imgs/preview-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified imgs/version.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 15 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,32 @@
> 3. If you encounter any problems, don't panic, contact [@X1a0He](https://t.me/X1a0He) on Telegram or use the Python
version. Many thanks to [Drovosek01](https://github.com/Drovosek01) for
the [adobe-packager](https://github.com/Drovosek01/adobe-packager)
> 4. ⚠️⚠️⚠️**All Adobe apps in Adobe Downloader are from official Adobe channels and are not cracked versions.**
> 4. ⚠️⚠️⚠️ **All Adobe apps in Adobe Downloader are from official Adobe channels and are not cracked versions.**
> 5. ❌❌❌ **Do not use an external hard drive or any USB to store it, as this will cause permission issues, I do not have
the patience to solve any about permission issues**

## 📔Latest Log

- For historical update logs, please go to [Update Log](update-log.md)

- 2024-11-06 10:00 Update Log
- 2024-11-06 15:15 Update Log

```markdown
1. Added default configuration settings and prompts when the program is started for the first time
2. Added optional architecture downloads, please select in settings
3. Fixed the problem of version detection error (only checks whether the file exists, not whether it is complete)
4. Removed the language selection and directory selection on the main interface and moved them to settings
5. Added architecture prompts on the version selection page

====================

1. 增加程序首次启动时的默认配置设定与提示
2. 增加可选架构下载,请在设置中进行选择
3. 修复了版本已存在检测错误的问题 (仅检测文件是否存在,并不会检测是否完整)
3. 修复了版本已存在检测错误的问题 \(仅检测文件是否存在,并不会检测是否完整\)
4. 移除主界面的语言选择和目录选择,移动到了设置中
5. 版本选择页面增加架构提示
6. 移除了安装程序的机制,现在不会再生成安装程序

====================

1. Added default configuration settings and prompts when the program is started for the first time
2. Added optional architecture downloads, please select in settings
3. Fixed the problem of version detection error \(only checks whether the file exists, not whether it is complete\)
4. Removed the language selection and directory selection on the main interface and moved them to settings
5. Added architecture prompts on the version selection page
6. Removed the installer mechanism, and now no installer will be generated
```

### Language friendly
Expand Down
4 changes: 3 additions & 1 deletion update-log.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Change Log

- 2024-11-06 10:00 更新日志
- 2024-11-06 15:15 更新日志

```markdown
1. 增加程序首次启动时的默认配置设定与提示
2. 增加可选架构下载,请在设置中进行选择
3. 修复了版本已存在检测错误的问题 \(仅检测文件是否存在,并不会检测是否完整\)
4. 移除主界面的语言选择和目录选择,移动到了设置中
5. 版本选择页面增加架构提示
6. 移除了安装程序的机制,现在不会再生成安装程序

====================

Expand All @@ -16,6 +17,7 @@
3. Fixed the problem of version detection error \(only checks whether the file exists, not whether it is complete\)
4. Removed the language selection and directory selection on the main interface and moved them to settings
5. Added architecture prompts on the version selection page
6. Removed the installer mechanism, and now no installer will be generated
```

- 2024-11-05 21:15 更新日志
Expand Down

0 comments on commit 51c19c8

Please sign in to comment.