Fix bug: missing fields
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go-v2/aws"
|
"github.com/aws/aws-sdk-go-v2/aws"
|
||||||
"github.com/aws/aws-sdk-go-v2/credentials"
|
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||||
@@ -61,6 +62,15 @@ func parseS3URL(s3URL string) (*S3Config, error) {
|
|||||||
|
|
||||||
// processS3Bucket processes an S3 bucket and generates index files
|
// processS3Bucket processes an S3 bucket and generates index files
|
||||||
func processS3Bucket(s3Config *S3Config, opts *indexgen.Options) error {
|
func processS3Bucket(s3Config *S3Config, opts *indexgen.Options) error {
|
||||||
|
if opts.DryRun {
|
||||||
|
// In dry run mode, just show what would be done without connecting
|
||||||
|
fmt.Printf("Would connect to S3 endpoint: %s\n", s3Config.Endpoint)
|
||||||
|
fmt.Printf("Would list objects in bucket: %s\n", s3Config.Bucket)
|
||||||
|
fmt.Printf("Would write S3 index file: %s\n", opts.OutputFile)
|
||||||
|
fmt.Printf("Note: Dry run mode - no actual S3 connection made\n")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Get credentials from environment variables
|
// Get credentials from environment variables
|
||||||
accessKey := os.Getenv("AWS_ACCESS_KEY_ID")
|
accessKey := os.Getenv("AWS_ACCESS_KEY_ID")
|
||||||
secretKey := os.Getenv("AWS_SECRET_ACCESS_KEY")
|
secretKey := os.Getenv("AWS_SECRET_ACCESS_KEY")
|
||||||
@@ -126,15 +136,16 @@ func processS3Bucket(s3Config *S3Config, opts *indexgen.Options) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
entry := indexgen.FileEntry{
|
entry := indexgen.FileEntry{
|
||||||
Name: keyName,
|
Name: keyName,
|
||||||
Path: keyName,
|
Path: keyName,
|
||||||
IsDir: false,
|
IsDir: false,
|
||||||
Size: *obj.Size,
|
Size: *obj.Size,
|
||||||
ModTime: *obj.LastModified,
|
ModTime: *obj.LastModified,
|
||||||
IsSymlink: false,
|
IsSymlink: false,
|
||||||
IconType: indexgen.GetIconType(keyName),
|
IconType: indexgen.GetIconType(keyName),
|
||||||
SizePretty: indexgen.PrettySize(*obj.Size),
|
SizePretty: indexgen.PrettySize(*obj.Size),
|
||||||
ModTimeISO: obj.LastModified.Format("2006-01-02T15:04:05Z"),
|
ModTimeISO: obj.LastModified.Format(time.RFC3339),
|
||||||
|
ModTimeHuman: obj.LastModified.Format(time.RFC822),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set CSS class based on file type
|
// Set CSS class based on file type
|
||||||
@@ -193,15 +204,15 @@ func generateS3HTML(entries []indexgen.FileEntry, opts *indexgen.Options) error
|
|||||||
|
|
||||||
// Prepare template data (similar to ProcessDir in indexgen)
|
// Prepare template data (similar to ProcessDir in indexgen)
|
||||||
data := struct {
|
data := struct {
|
||||||
DirName string
|
DirName string
|
||||||
Entries []indexgen.FileEntry
|
Entries []indexgen.FileEntry
|
||||||
TopDir string
|
DirAppend bool
|
||||||
Hostname string
|
OutputFile string
|
||||||
}{
|
}{
|
||||||
DirName: opts.TopDir, // Use bucket name as directory name
|
DirName: opts.TopDir, // Use bucket name as directory name
|
||||||
Entries: entries,
|
Entries: entries,
|
||||||
TopDir: opts.TopDir,
|
DirAppend: opts.DirAppend,
|
||||||
Hostname: "S3 Bucket", // Could be improved to show actual endpoint
|
OutputFile: opts.OutputFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create output file
|
// Create output file
|
||||||
|
|||||||
Reference in New Issue
Block a user