{"id":483,"date":"2019-12-27T05:10:00","date_gmt":"2019-12-26T16:10:00","guid":{"rendered":"http:\/\/wp.gaborhargitai.hu\/?p=483"},"modified":"2019-12-27T05:12:59","modified_gmt":"2019-12-26T16:12:59","slug":"clear-google-drive-file-stream-cache-under-macos-on-user-login-delete-empty-the-content_cache-folder-automatically","status":"publish","type":"post","link":"https:\/\/wp.gaborhargitai.hu\/clear-google-drive-file-stream-cache-under-macos-on-user-login-delete-empty-the-content_cache-folder-automatically\/","title":{"rendered":"Clear Google Drive File Stream Cache under macOS on User Login – Delete\/Empty the content_cache folder automatically"},"content":{"rendered":"\n

I’m in a hurry! TL;DR<\/strong>?<\/h2>\n\n\n\n
  1. Download and unzip this Automator script<\/a> to your Home dir (or iCloud Drive)<\/li>
  2. open System Preferences<\/strong> > Users & Groups<\/strong><\/li>
  3. select your user on the left<\/li>
  4. switch to Login Items<\/strong> on the right<\/li>
  5. click the “+” at the bottom of the list<\/li>
  6. select the Clear Google File Stream Cache<\/strong> script you’ve just downloaded<\/li>
  7. Done!<\/li><\/ol>\n\n\n\n

    What’s the problem?<\/h2>\n\n\n\n

    Google Drive File Stream<\/a> is a compelling option among cloud storage services – as the name implies, it does not store all<\/em> your files physically on your disk, but rather, it streams<\/em> them. While technically this is somewhat true, there is a catch here: a local cache is built to speed things up (and save bandwidth on both ends).<\/p>\n\n\n\n

    Problem is, the cache size<\/strong> configuration is not behaving as it should: there is a KB article that aims to tell you how to configure<\/a> the Google Drive File Stream cache policy, in reality it didn’t work me and neither did for a handful of other users. Depending on usage, the content_cache<\/strong> folder easily eats up anywhere between 40 to 110 gigabytes of storage.<\/p>\n\n\n\n

    What can we do about it?<\/h2>\n\n\n\n

    There already are a number of threads about this problem, click here to check the one I’ve posted to as well<\/a> – in the meantime, I’ve put together a small hack-ish solution to clear the cache on login which essentially means deleting the content_cache<\/code> folder within the user’s Library\/Application Support\/Google\/DriveFS<\/code> using the default shell provided by macOS.<\/p>\n\n\n\n

    You can check the TL;DR<\/strong> above or follow along and do the steps yourself to achieve the same result.<\/p>\n\n\n\n

    We’re going to use a basic find<\/code> command within a shell script<\/code> that is run via an Apple Automator<\/strong> application every time the user logs in. Alternatively, one could also use plist files for launch demons at login.<\/em><\/p>\n\n\n\n

    Let’s get started!<\/p>\n\n\n\n

    Creating the Apple Automator script<\/h4>\n\n\n\n
    1. start the Automator<\/strong> app either via Launchpad<\/em>, Spotlight<\/em> or Finder > Applications<\/em><\/li>
    2. once it has started, select Application<\/strong> and click Choose<\/strong><\/li>
    3. in the top-left corner click on Library<\/strong> (if it is not already visible<\/li>
    4. select “Library”<\/strong> at the top of the tree list<\/li>
    5. search for “Run Shell Script<\/strong>” and add it via double-clicking<\/strong> on it<\/li>
    6. for Shell<\/strong> select \/bin\/sh<\/strong><\/li>
    7. put the following into the text field:
      find ~\/Library\/Application\\ Support\/Google\/DriveFS -type d -exec test -e '{}'\/content_cache \\; -exec rm -rf {}\/content_cache \\;<\/code><\/li>
    8. click on File > Save…<\/li>
    9. set the File Format<\/strong> to Application<\/strong><\/li>
    10. save it to your Home folder or iCloud Drive with a descriptive name, like “Clear Google File Stream Cache<\/strong>“<\/li><\/ol>\n\n\n\n

      Adding the cache cleaning script to the Login Items<\/h4>\n\n\n\n
      1. open System Preferences<\/strong> > Users & Groups<\/strong><\/li>
      2. select your user on the left<\/li>
      3. switch to the Login Items<\/strong> tab on the right<\/li>
      4. click the “+” at the bottom of the list<\/li>
      5. select the Clear Google File Stream Cache<\/strong> script you’ve just saved<\/li>
      6. Done!<\/li><\/ol>\n\n\n\n

        Now the Google Drive File Stream cache is cleared by removing the content_cache<\/code> directory every time during the user’s login.<\/p>\n","protected":false},"excerpt":{"rendered":"

        I’m in a hurry! TL;DR? Download and unzip this Automator script to your Home dir (or iCloud Drive) open System Preferences > Users & Groups select your user on the left switch to Login Items on the right click the “+” at the bottom of the list select the Clear Google File Stream Cache script […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[34,17],"tags":[],"_links":{"self":[{"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/posts\/483"}],"collection":[{"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/comments?post=483"}],"version-history":[{"count":10,"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/posts\/483\/revisions"}],"predecessor-version":[{"id":493,"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/posts\/483\/revisions\/493"}],"wp:attachment":[{"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/media?parent=483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/categories?post=483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/tags?post=483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}