Skip to content
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

Feature/brave cache #76

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions Contents/MacOS/startupRAMDiskandCacheMover.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,54 @@ move_chrome_chanary_cache()
fi
}

#
# Brave Cache
#

# Create a directory for Brave in the ramdisk
make_brave_dir()
{
/bin/mkdir -pv "${USERRAMDISK}"/Brave-Browser
}

# Move existing Brave cache to ramdisk
move_brave_cache()
{
/bin/mkdir -p /tmp/Brave-Browser
/bin/mv ~/Library/Caches/BraveSoftware/Brave-Browser/* /tmp/Brave-Browser
/bin/mv /tmp/Brave-Browser/* "${USERRAMDISK}"/Brave-Browser
/bin/rm -rf ~/Library/Caches/BraveSoftware/Brave-Browser

}

# Link Brave cache to ramdisk
link_brave_dir()
{
/bin/ln -v -s "${USERRAMDISK}"/Brave-Browser ~/Library/Caches/BraveSoftware/Brave-Browser
}

# Check what to do with brave
check_brave_cache()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR.
What if you simplify adding this browser by joining all the separate functions you did into one as it is done for other browsers, i.e chrome?

The ln behaviour should not be changing, it will break many things for them I suspect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I broke it up into several functions because I needed to do several more than once to prepare for previously-enabled cache. If you want me to do it I can make it a single function and... copy and paste some code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And speaking of the ln behaviour: it cost me a lot of time to figure out the problem. I was not expecting it as system tools usually behave as expected

{
if [ -d "/Users/${USER}/Library/Caches/BraveSoftware/Brave-Browser" ]; then
if user_response "${MSG_PROMPT_FOUND}" 'Brave'"${MSG_MOVE_CACHE}" ; then
close_app "Brave Browser"
make_brave_dir
move_brave_cache
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

body of the function could be just added here.

link_brave_dir
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider replacing this line with line 225:

     /bin/ln -v -s "${USERRAMDISK}"/Brave-Browser ~/Library/Caches/BraveSoftware/Brave-Browser 

it is used once only, does not needs to be a func

/bin/rm -rf /tmp/Brave-Browser
# and let's create a flag for next run that we moved the cache.
echo "";
fi
elif [ -L "/Users/${USER}/Library/Caches/BraveSoftware/Brave-Browser" ]; then
echo "Brave cache already moved"
close_app "Brave Browser"
make_brave_dir
else
echo "No Brave folder has been found. Skipping."
fi
}

#
# Safari Cache
#
Expand Down Expand Up @@ -386,6 +434,7 @@ main() {
move_safari_cache
move_idea_cache
move_ideace_cache
check_brave_cache
# create intermediate folder for intellij projects output
create_intermediate_folder_for_intellij_projects
move_itunes_cache
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Supported apps (you can add yours):
* [IntelliJ Idea 14/15](https://www.jetbrains.com/idea/download/)
* [Google Chrome](https://support.google.com/chrome/answer/95346?hl=en)
* [Google Canary](https://www.google.com/chrome/browser/canary.html)
* [Brave](https://brave.com/)
* Safari
* iTunes
* [Android studio](http://developer.android.com/sdk/index.html)
Expand Down