Compare commits
2 Commits
05ed4dd4ed
...
v1.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
| be63064bee | |||
| cd259e01a3 |
@@ -21,6 +21,12 @@ go build -o canvasarchiver ./cmd/canvasarchiver
|
||||
./canvasarchiver
|
||||
```
|
||||
|
||||
Or
|
||||
```bash
|
||||
./canvasarchiver -fo
|
||||
```
|
||||
For files-only mode.
|
||||
|
||||
2. On first run, you'll be prompted to authenticate:
|
||||
- Visit the provided OAuth URL
|
||||
- Authorize the application
|
||||
|
||||
@@ -17,21 +17,19 @@ import (
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
HTTPClient *http.Client
|
||||
AccessToken string
|
||||
CourseID string
|
||||
CourseName string
|
||||
FilesOnly bool
|
||||
downloadedFiles map[string]bool
|
||||
HTTPClient *http.Client
|
||||
AccessToken string
|
||||
CourseID string
|
||||
CourseName string
|
||||
FilesOnly bool
|
||||
}
|
||||
|
||||
func NewClient(httpClient *http.Client, accessToken, courseID string, filesOnly bool) *Client {
|
||||
return &Client{
|
||||
HTTPClient: httpClient,
|
||||
AccessToken: accessToken,
|
||||
CourseID: courseID,
|
||||
FilesOnly: filesOnly,
|
||||
downloadedFiles: make(map[string]bool),
|
||||
HTTPClient: httpClient,
|
||||
AccessToken: accessToken,
|
||||
CourseID: courseID,
|
||||
FilesOnly: filesOnly,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,13 +82,6 @@ func (c *Client) DownloadCourseFiles(root string) {
|
||||
fileCount := 0
|
||||
for _, file := range files {
|
||||
|
||||
if c.FilesOnly {
|
||||
if c.downloadedFiles[file.DisplayName] {
|
||||
continue
|
||||
}
|
||||
c.downloadedFiles[file.DisplayName] = true
|
||||
}
|
||||
|
||||
rawFolderPath := folderMap[file.FolderID]
|
||||
safeFolderPath := utils.SanitizePath(rawFolderPath)
|
||||
|
||||
@@ -232,18 +223,11 @@ func (c *Client) downloadModuleFile(item models.ModuleItem, dir string) {
|
||||
return
|
||||
}
|
||||
|
||||
if c.FilesOnly {
|
||||
if c.downloadedFiles[fileMeta.DisplayName] {
|
||||
return
|
||||
}
|
||||
c.downloadedFiles[fileMeta.DisplayName] = true
|
||||
}
|
||||
|
||||
ext := filepath.Ext(fileMeta.DisplayName)
|
||||
origBase := strings.TrimSuffix(fileMeta.DisplayName, ext)
|
||||
|
||||
fileName := fileMeta.DisplayName
|
||||
if !c.FilesOnly && !strings.EqualFold(origBase, item.Title) && item.Title != "" {
|
||||
if !strings.EqualFold(origBase, item.Title) && item.Title != "" {
|
||||
fileName = fmt.Sprintf("%s (%s)%s", origBase, item.Title, ext)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user