[patch] 修改逻辑: 在用户误触或开了多个GUI程序的时候不能同时建立多个连接 确保一个账号只能建立一个与后端的连接 友好提示的集成review 修改powershell语法问题
This commit is contained in:
@@ -40,7 +40,7 @@ def get_ks3_connection():
|
|||||||
KS3_SECRET_KEY,
|
KS3_SECRET_KEY,
|
||||||
host=KS3_ENDPOINT,
|
host=KS3_ENDPOINT,
|
||||||
is_secure=KS3_IS_SECURE,
|
is_secure=KS3_IS_SECURE,
|
||||||
timeout=300,
|
timeout=1800, # Increase timeout to 30 minutes for large files
|
||||||
)
|
)
|
||||||
logger.info(f"KS3 connection established: {KS3_ENDPOINT}")
|
logger.info(f"KS3 connection established: {KS3_ENDPOINT}")
|
||||||
return connection
|
return connection
|
||||||
@@ -72,18 +72,34 @@ def find_latest_installer():
|
|||||||
return latest_installer
|
return latest_installer
|
||||||
|
|
||||||
|
|
||||||
|
def progress_callback(uploaded_bytes, total_bytes):
|
||||||
|
"""Upload progress callback"""
|
||||||
|
if total_bytes > 0:
|
||||||
|
percentage = (uploaded_bytes / total_bytes) * 100
|
||||||
|
uploaded_mb = uploaded_bytes / 1024 / 1024
|
||||||
|
total_mb = total_bytes / 1024 / 1024
|
||||||
|
logger.info(f"Upload progress: {percentage:.1f}% ({uploaded_mb:.1f}/{total_mb:.1f} MB)")
|
||||||
|
|
||||||
|
|
||||||
def upload_installer(connection, installer_path):
|
def upload_installer(connection, installer_path):
|
||||||
"""Upload installer to KS3"""
|
"""Upload installer to KS3 with progress tracking"""
|
||||||
try:
|
try:
|
||||||
bucket = connection.get_bucket(KS3_BUCKET)
|
bucket = connection.get_bucket(KS3_BUCKET)
|
||||||
ks3_key = f"{KS3_PREFIX}{installer_path.name}"
|
ks3_key = f"{KS3_PREFIX}{installer_path.name}"
|
||||||
|
|
||||||
|
file_size = installer_path.stat().st_size
|
||||||
|
file_size_mb = file_size / 1024 / 1024
|
||||||
|
|
||||||
logger.info(f"Starting upload to KS3...")
|
logger.info(f"Starting upload to KS3...")
|
||||||
logger.info(f"Target path: {ks3_key}")
|
logger.info(f"Target path: {ks3_key}")
|
||||||
|
logger.info(f"File size: {file_size_mb:.2f} MB")
|
||||||
|
logger.info(f"Estimated time: ~{int(file_size_mb / 2)} seconds (assuming 2MB/s)")
|
||||||
|
logger.info("Please wait, this may take several minutes...")
|
||||||
|
|
||||||
key = bucket.new_key(ks3_key)
|
key = bucket.new_key(ks3_key)
|
||||||
|
|
||||||
# Upload file with public read permission (reference: bulk_upload_static_to_ks3.py)
|
# Upload file with public read permission and progress tracking
|
||||||
|
# Use cb parameter for progress callback (called every 5% or every 10MB)
|
||||||
key.set_contents_from_filename(
|
key.set_contents_from_filename(
|
||||||
str(installer_path),
|
str(installer_path),
|
||||||
headers={
|
headers={
|
||||||
@@ -93,7 +109,9 @@ def upload_installer(connection, installer_path):
|
|||||||
'x-kss-storage-class': 'STANDARD',
|
'x-kss-storage-class': 'STANDARD',
|
||||||
'x-kss-acl': 'public-read' # Set public read permission in headers
|
'x-kss-acl': 'public-read' # Set public read permission in headers
|
||||||
},
|
},
|
||||||
policy='public-read' # Set ACL policy
|
policy='public-read', # Set ACL policy
|
||||||
|
cb=progress_callback, # Progress callback function
|
||||||
|
num_cb=10 # Call callback 10 times during upload (every 10%)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Generate download URL (using KS3 third-level domain format)
|
# Generate download URL (using KS3 third-level domain format)
|
||||||
@@ -101,12 +119,18 @@ def upload_installer(connection, installer_path):
|
|||||||
protocol = 'https' if KS3_IS_SECURE else 'http'
|
protocol = 'https' if KS3_IS_SECURE else 'http'
|
||||||
download_url = f"{protocol}://{KS3_BUCKET}.{KS3_ENDPOINT}/{ks3_key}"
|
download_url = f"{protocol}://{KS3_BUCKET}.{KS3_ENDPOINT}/{ks3_key}"
|
||||||
|
|
||||||
logger.info(f"Upload successful!")
|
logger.info("")
|
||||||
|
logger.info("=" * 70)
|
||||||
|
logger.info("Upload successful!")
|
||||||
logger.info(f"Download URL: {download_url}")
|
logger.info(f"Download URL: {download_url}")
|
||||||
|
logger.info("=" * 70)
|
||||||
|
|
||||||
return download_url
|
return download_url
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
logger.error("")
|
||||||
|
logger.error("=" * 70)
|
||||||
logger.error(f"Upload failed: {e}")
|
logger.error(f"Upload failed: {e}")
|
||||||
|
logger.error("=" * 70)
|
||||||
import traceback
|
import traceback
|
||||||
logger.error(traceback.format_exc())
|
logger.error(traceback.format_exc())
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -354,23 +354,46 @@ jobs:
|
|||||||
- name: Upload installer to KS3
|
- name: Upload installer to KS3
|
||||||
if: success()
|
if: success()
|
||||||
shell: powershell
|
shell: powershell
|
||||||
|
timeout-minutes: 30
|
||||||
run: |
|
run: |
|
||||||
Write-Host "==========================================";
|
Write-Host "==========================================";
|
||||||
Write-Host "Step 4.8: Upload installer to KS3";
|
Write-Host "Step 4.8: Upload installer to KS3";
|
||||||
Write-Host "==========================================";
|
Write-Host "==========================================";
|
||||||
|
Write-Host "NOTE: Large file upload may take 5-10 minutes";
|
||||||
|
Write-Host "";
|
||||||
|
|
||||||
# Install KS3 SDK
|
# Install KS3 SDK
|
||||||
Write-Host "Installing KS3 SDK...";
|
Write-Host "Installing KS3 SDK...";
|
||||||
python -m pip install ks3sdk --quiet;
|
python -m pip install ks3sdk --quiet;
|
||||||
|
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
Write-Host "ERROR: Failed to install ks3sdk";
|
||||||
|
Write-Host "Skipping KS3 upload (version release continues)";
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Starting upload process...";
|
||||||
|
Write-Host "This may take several minutes, please be patient...";
|
||||||
|
Write-Host "";
|
||||||
|
|
||||||
|
# Run upload script
|
||||||
python .gitea/scripts/upload_installer_to_ks3.py;
|
python .gitea/scripts/upload_installer_to_ks3.py;
|
||||||
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -eq 0) {
|
||||||
Write-Host "KS3 upload failed, but version release continues";
|
Write-Host "";
|
||||||
Write-Host " You can manually upload the installer later";
|
Write-Host "OK: Installer uploaded to KS3 successfully";
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Installer uploaded to KS3 successfully";
|
Write-Host "";
|
||||||
|
Write-Host "WARNING: KS3 upload failed (exit code: $LASTEXITCODE)";
|
||||||
|
Write-Host "NOTICE: Version release continues";
|
||||||
|
Write-Host "NOTICE: You can manually upload the installer later";
|
||||||
|
Write-Host "";
|
||||||
|
Write-Host "Manual upload steps:";
|
||||||
|
Write-Host " 1. Find installer in: installer/output/";
|
||||||
|
Write-Host " 2. Upload to KS3 bucket: shuidrop-chat-server";
|
||||||
|
Write-Host " 3. Target path: installers/";
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "";
|
Write-Host "";
|
||||||
|
|
||||||
# Step 5: Commit version changes
|
# Step 5: Commit version changes
|
||||||
|
|||||||
Reference in New Issue
Block a user