-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed Optimization Download Process and added some new features #26
Open
777Denoiser
wants to merge
20
commits into
cisco-open:main
Choose a base branch
from
777Denoiser:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+305
−122
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
13a2c95
"not yet finished implementing the opti-downloader into the grabit co…
777Denoiser 4e767d8
"Finished implementing the opti-downloader into the grabit codebase, …
777Denoiser 1d0913e
Delete .idea/modules.xml
777Denoiser ab80f8b
Delete .idea/misc.xml
777Denoiser cd3052f
Delete .idea/dbnavigator.xml
777Denoiser d9e05ca
Delete .idea/grabit.iml
777Denoiser 5e7cf32
Delete .idea/inspectionProfiles/Project_Default.xml
777Denoiser 249b385
Delete .idea/inspectionProfiles/profiles_settings.xml
777Denoiser 4389299
Delete .idea/vcs.xml
777Denoiser a70c1ee
Delete .idea/.gitignore
777Denoiser 1aae37b
I streamlined and enhanced the download process in grabit
777Denoiser c4eac65
Update add.go
777Denoiser a39b5e3
Update download.go
777Denoiser 35163b5
Update lock.go
777Denoiser c0f58a6
Update main.go
777Denoiser cb00419
Update root_test.go
777Denoiser 3cca4df
Update lock.go
777Denoiser 2807f17
Update lock_test.go
777Denoiser 56ee133
Update lock_test.go
777Denoiser a03114a
Update lock.go
777Denoiser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea | ||
dist/ | ||
grabit | ||
grabit.lock | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ package cmd | |
|
||
import ( | ||
"github.com/cisco-open/grabit/internal" | ||
"github.com/rs/zerolog" | ||
"github.com/rs/zerolog/log" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
|
@@ -19,10 +21,20 @@ func addDownload(cmd *cobra.Command) { | |
downloadCmd.Flags().StringArray("tag", []string{}, "Only download the resources with the given tag") | ||
downloadCmd.Flags().StringArray("notag", []string{}, "Only download the resources without the given tag") | ||
downloadCmd.Flags().String("perm", "", "Optional permissions for the downloaded files (e.g. '644')") | ||
downloadCmd.Flags().BoolP("verbose", "v", false, "Enable verbose output") | ||
cmd.AddCommand(downloadCmd) | ||
} | ||
|
||
func runFetch(cmd *cobra.Command, args []string) error { | ||
logLevel, _ := cmd.Flags().GetString("log-level") | ||
level, _ := zerolog.ParseLevel(logLevel) | ||
zerolog.SetGlobalLevel(level) | ||
|
||
if level <= zerolog.DebugLevel { | ||
log.Debug().Msg("Starting download") | ||
// Add more debug logs as needed | ||
} | ||
|
||
lockFile, err := cmd.Flags().GetString("lock-file") | ||
if err != nil { | ||
return err | ||
|
@@ -47,9 +59,21 @@ func runFetch(cmd *cobra.Command, args []string) error { | |
if err != nil { | ||
return err | ||
} | ||
err = lock.Download(dir, tags, notags, perm) | ||
|
||
d := cmd.Context().Value("downloader").(*downloader.Downloader) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to go, see my comment above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, am i to completely scrap this apologies i will scrap this verbose logging. |
||
|
||
if verbose { | ||
log.Debug().Str("lockFile", lockFile).Str("dir", dir).Strs("tags", tags).Strs("notags", notags).Str("perm", perm).Msg("Starting download") | ||
} | ||
|
||
err = lock.Download(dir, tags, notags, perm, d) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if verbose { | ||
log.Debug().Msg("Download completed successfully") | ||
} | ||
|
||
return nil | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/cisco-open/grabit/internal" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var updateCmd = &cobra.Command{ | ||
Use: "update [URL]", | ||
Short: "Update a resource", | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
lockFile, _ := cmd.Flags().GetString("lock-file") | ||
lock, err := internal.NewLock(lockFile, false) | ||
if err != nil { | ||
return err | ||
} | ||
return lock.UpdateResource(args[0]) | ||
}, | ||
} | ||
|
||
func AddUpdate(cmd *cobra.Command) { | ||
cmd.AddCommand(updateCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/cisco-open/grabit/internal" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var verifyCmd = &cobra.Command{ | ||
Use: "verify", | ||
Short: "Verify the integrity of downloaded resources", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
lockFile, _ := cmd.Flags().GetString("lock-file") | ||
lock, err := internal.NewLock(lockFile, false) | ||
if err != nil { | ||
return err | ||
} | ||
return lock.VerifyIntegrity() | ||
}, | ||
} | ||
|
||
func AddVerify(cmd *cobra.Command) { | ||
cmd.AddCommand(verifyCmd) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think adding an explicit way to set the log level isn't a bad idea... but it should not be done in this PR. Let's keep this PR focused on one thing please: adding the optimization to skip the downloading if the resource is there and its integrity matches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its already implemented and is working via a command, apologies but I feel like we will have more to show because of this during our demo, but I understand and will focus #27 on the optimization skipping of the download. and the fact that only me and dylan have something to show that is working but it's fine because its only mid-semester and we have the rest of the semester to do what is needed to be done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nevermind i just read your other comment and will scrap this