mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-05 23:26:38 +08:00
[优化] 代码优化
This commit is contained in:
@@ -612,7 +612,7 @@ func buildSnapshotPagesDeployment(projectID *uint) (*snapshotPagesDeployment, er
|
||||
return nil, errors.New("Pages 激活部署不属于当前项目")
|
||||
}
|
||||
localRoot := fmt.Sprintf("%s/deployments/%d/current", openrestyrender.PagesDirPlaceholder, deployment.ID)
|
||||
cleanedRootDir := strings.TrimSpace(deployment.RootDir)
|
||||
cleanedRootDir := strings.TrimSpace(project.RootDir)
|
||||
if cleanedRootDir != "" {
|
||||
localRoot = path.Join(localRoot, cleanedRootDir)
|
||||
}
|
||||
@@ -622,7 +622,7 @@ func buildSnapshotPagesDeployment(projectID *uint) (*snapshotPagesDeployment, er
|
||||
DeploymentID: deployment.ID,
|
||||
DeploymentNumber: deployment.DeploymentNumber,
|
||||
Checksum: deployment.Checksum,
|
||||
EntryFile: deployment.EntryFile,
|
||||
EntryFile: project.EntryFile,
|
||||
SPAFallbackEnabled: project.SPAFallbackEnabled,
|
||||
SPAFallbackPath: normalizeStoredPagesFallbackPath(project.SPAFallbackPath),
|
||||
APIProxyEnabled: project.APIProxyEnabled,
|
||||
|
||||
@@ -74,8 +74,6 @@ type PagesDeploymentView struct {
|
||||
Status string `json:"status"`
|
||||
FileCount int `json:"file_count"`
|
||||
TotalSize int64 `json:"total_size"`
|
||||
RootDir string `json:"root_dir"`
|
||||
EntryFile string `json:"entry_file"`
|
||||
CreatedBy string `json:"created_by"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ActivatedAt *time.Time `json:"activated_at"`
|
||||
@@ -288,8 +286,6 @@ func UploadPagesDeployment(projectID uint, fileHeader *multipart.FileHeader, roo
|
||||
ArtifactPath: artifactPath,
|
||||
FileCount: manifest.FileCount,
|
||||
TotalSize: manifest.TotalSize,
|
||||
RootDir: rootDir,
|
||||
EntryFile: manifest.EntryFile,
|
||||
CreatedBy: strings.TrimSpace(createdBy),
|
||||
}
|
||||
if err := tx.Create(deployment).Error; err != nil {
|
||||
@@ -547,8 +543,6 @@ func buildPagesDeploymentView(deployment *model.PagesDeployment) *PagesDeploymen
|
||||
Status: deployment.Status,
|
||||
FileCount: deployment.FileCount,
|
||||
TotalSize: deployment.TotalSize,
|
||||
RootDir: deployment.RootDir,
|
||||
EntryFile: deployment.EntryFile,
|
||||
CreatedBy: deployment.CreatedBy,
|
||||
CreatedAt: deployment.CreatedAt,
|
||||
ActivatedAt: deployment.ActivatedAt,
|
||||
|
||||
@@ -268,8 +268,8 @@ func TestUploadPagesDeploymentWithTopLevelFolder(t *testing.T) {
|
||||
if deployment.FileCount != 2 {
|
||||
t.Fatalf("expected 2 files, got %d", deployment.FileCount)
|
||||
}
|
||||
if deployment.EntryFile != "index.html" {
|
||||
t.Fatalf("expected EntryFile to be index.html, got %q", deployment.EntryFile)
|
||||
if project.EntryFile != "index.html" {
|
||||
t.Fatalf("expected EntryFile to be index.html, got %q", project.EntryFile)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,11 +354,11 @@ func TestUploadPagesDeploymentWithRootDir(t *testing.T) {
|
||||
if deployment.FileCount != 3 {
|
||||
t.Fatalf("expected 3 files, got %d", deployment.FileCount)
|
||||
}
|
||||
if deployment.RootDir != "build" {
|
||||
t.Fatalf("expected RootDir to be 'build', got %q", deployment.RootDir)
|
||||
if project.RootDir != "build" {
|
||||
t.Fatalf("expected RootDir to be 'build', got %q", project.RootDir)
|
||||
}
|
||||
if deployment.EntryFile != "index.html" {
|
||||
t.Fatalf("expected EntryFile to be 'index.html', got %q", deployment.EntryFile)
|
||||
if project.EntryFile != "index.html" {
|
||||
t.Fatalf("expected EntryFile to be 'index.html', got %q", project.EntryFile)
|
||||
}
|
||||
|
||||
// 2. Update project configuration to a wrong entry file relative to root directory, upload should fail
|
||||
|
||||
Reference in New Issue
Block a user