Skip to content

Commit

Permalink
Merge pull request #18 from Beebeeoii/hotfix-v1.1.2
Browse files Browse the repository at this point in the history
Hotfix v1.1.2
  • Loading branch information
Jia Wei Lee authored Dec 31, 2021
2 parents 7bb45e1 + fa0aa21 commit 6200594
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 25 deletions.
4 changes: 2 additions & 2 deletions FyneApp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Website = "https://github.com/beebeeoii/lominus"
Icon = "./assets/app-icon.png"
Name = "Lominus"
ID = "com.beebeeoii.lominus"
Version = "1.1.1"
Build = 50
Version = "1.1.2"
Build = 60
2 changes: 1 addition & 1 deletion internal/lominus/lominus.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package lominus

const APP_NAME = "Lominus"
const APP_ID = "com.lominus.beebeeoii"
const APP_VERSION = "1.1.1"
const APP_VERSION = "1.1.2"

const LOCK_FILE_NAME = "lominus.lock"

Expand Down
39 changes: 19 additions & 20 deletions pkg/api/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"errors"
"io"
"log"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -56,40 +57,38 @@ func (req DocumentRequest) GetAllFolders() ([]Folder, error) {
return folder, nil
}

// Deprecated - build DocumentRequest with a Folder instead of a module instead, and call getRootFiles() directly
func (req DocumentRequest) GetAllFiles() ([]File, error) {
files := []File{}
if req.Mode != GET_ALL_FILES {
return files, errors.New("mode mismatched: ensure DocumentRequest mode is GET_ALL_FILES (1)")
}

req.Mode = 0
folders, err := req.GetAllFolders()
rootFilesReq, rootFilesBuildErr := BuildDocumentRequest(Folder{
Id: req.Module.Id,
Name: req.Module.ModuleCode,
Downloadable: true,
Ancestors: []string{strings.TrimSpace(req.Module.ModuleCode)},
HasSubFolder: true,
}, GET_FILES)
if rootFilesBuildErr != nil {
return files, rootFilesBuildErr
}

baseFiles, err := rootFilesReq.getRootFiles()
log.Println(baseFiles)
if err != nil {
return files, err
}
files = append(files, baseFiles...)

for _, folder := range folders {
folder.Ancestors = append(folder.Ancestors, strings.TrimSpace(folder.Name))

rootFilesReq, rootFilesBuildErr := BuildDocumentRequest(folder, get_files)
if rootFilesBuildErr != nil {
return files, rootFilesBuildErr
}

subFiles, err := rootFilesReq.getRootFiles()
if err != nil {
return files, err
}

files = append(files, subFiles...)
}
return files, nil
}

func (req DocumentRequest) getRootFiles() ([]File, error) {
files := []File{}
if req.Mode != get_files {
return files, errors.New("mode mismatched: ensure DocumentRequest mode is get_files (3)")
if req.Mode != GET_FILES {
return files, errors.New("mode mismatched: ensure DocumentRequest mode is GET_FILES (3)")
}

if !req.Folder.Downloadable {
Expand All @@ -110,7 +109,7 @@ func (req DocumentRequest) getRootFiles() ([]File, error) {
for _, subFolder := range subFolders {
subFolder.Ancestors = append(subFolder.Ancestors, req.Folder.Ancestors...)
subFolder.Ancestors = append(subFolder.Ancestors, strings.TrimSpace(subFolder.Name))
rootFilesReq, rootFilesBuildErr := BuildDocumentRequest(subFolder, get_files)
rootFilesReq, rootFilesBuildErr := BuildDocumentRequest(subFolder, GET_FILES)
if rootFilesBuildErr != nil {
return files, rootFilesBuildErr
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const (
GET_FOLDERS = 0
GET_ALL_FILES = 1
DOWNLOAD_FILE = 2
get_files = 3
GET_FILES = 3
)

const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0"
Expand Down Expand Up @@ -99,7 +99,7 @@ func BuildDocumentRequest(builder interface{}, mode int) (DocumentRequest, error
return DocumentRequest{}, errors.New("invalid arguments: DocumentRequest must be built using File to download")
}
urlEndpoint = DOWNLOAD_URL_ENDPOINT
case get_files:
case GET_FILES:
urlEndpoint = FILE_URL_ENDPOINT
default:
return DocumentRequest{}, errors.New("invalid arguments: mode provided is not a valid mode")
Expand Down

0 comments on commit 6200594

Please sign in to comment.