/ test-download-verification.sh
test-download-verification.sh
1 #!/bin/bash 2 3 echo "📥 Testing Download Verification" 4 echo "===============================" 5 6 # Set up test directory 7 DOWNLOAD_DIR="/tmp/keepsync-download-test" 8 rm -rf "$DOWNLOAD_DIR" 9 mkdir -p "$DOWNLOAD_DIR" 10 11 echo "📁 Created download directory: $DOWNLOAD_DIR" 12 13 # Change to KeepSync directory 14 cd /home/master/.local/share/containers/storage/volumes/coding/_data/coding/go-lang/keepSync 15 16 echo "📋 First, let's see what files are available in S3..." 17 18 # Create a simple test to download files using the provider directly 19 cat > test-download-files.go << 'EOF' 20 package main 21 22 import ( 23 "context" 24 "fmt" 25 "log" 26 "os" 27 "path/filepath" 28 29 "keepSync/internal/providers" 30 ) 31 32 func main() { 33 fmt.Println("📥 Testing file download from S3...") 34 35 // Create quantum provider 36 config := providers.QuantumS3Config{ 37 Bucket: "storage-a01", 38 Region: "us-east-1", 39 Endpoint: "https://s3.filebase.com", 40 AccessKey: "EF4A740258F43842F16E", 41 SecretKey: "ZUXkT90Fg8LTdC8QzrEnMSSubldd7eKsRyylukRD", 42 KeyName: "s3-quantum-key", 43 } 44 45 provider, err := providers.NewQuantumS3Provider(config) 46 if err != nil { 47 log.Fatalf("Failed to create provider: %v", err) 48 } 49 defer provider.Close() 50 51 ctx := context.Background() 52 downloadDir := "/tmp/keepsync-download-test" 53 54 // List files to see what's available 55 fmt.Println("📋 Listing available files...") 56 files, err := provider.List(ctx, "test-sync/") 57 if err != nil { 58 log.Fatalf("Failed to list files: %v", err) 59 } 60 61 fmt.Printf("📁 Found %d files:\n", len(files)) 62 for i, file := range files { 63 fmt.Printf(" %d. %s\n", i+1, file) 64 } 65 66 // Download each file 67 for _, file := range files { 68 if filepath.Dir(file) == "test-sync" { 69 filename := filepath.Base(file) 70 localPath := filepath.Join(downloadDir, filename) 71 72 fmt.Printf("📥 Downloading: %s -> %s\n", file, localPath) 73 74 if err := provider.Download(ctx, file, localPath); err != nil { 75 fmt.Printf("❌ Failed to download %s: %v\n", file, err) 76 } else { 77 fmt.Printf("✅ Successfully downloaded %s\n", filename) 78 79 // Check file size 80 if info, err := os.Stat(localPath); err == nil { 81 fmt.Printf(" 📏 File size: %d bytes\n", info.Size()) 82 } 83 84 // Show first few lines if it's a text file 85 if content, err := os.ReadFile(localPath); err == nil { 86 lines := string(content) 87 if len(lines) > 200 { 88 lines = lines[:200] + "..." 89 } 90 fmt.Printf(" 📄 Content preview: %s\n", lines) 91 } 92 } 93 } 94 } 95 96 fmt.Println("✅ Download test completed!") 97 } 98 EOF 99 100 echo "🔧 Running download test..." 101 go run test-download-files.go 102 103 echo "" 104 echo "📁 Files in download directory:" 105 ls -la "$DOWNLOAD_DIR/" 106 107 echo "" 108 echo "📖 Reading downloaded files..." 109 for file in "$DOWNLOAD_DIR"/*.txt; do 110 if [ -f "$file" ]; then 111 filename=$(basename "$file") 112 echo "" 113 echo "📄 $filename ($(wc -c < "$file") bytes):" 114 echo " First 3 lines:" 115 head -n 3 "$file" | sed 's/^/ /' 116 fi 117 done 118 119 # Cleanup 120 rm -f test-download-files.go 121 echo "" 122 echo "✅ Download verification completed!"