Skip to content

Commit

Permalink
Fix detecting own process in rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorgalvao committed Jan 19, 2022
1 parent ade6429 commit 1aebe80
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Workflow/gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Cache_file = File.join(ENV['alfred_workflow_cache'], 'cache.db')

# If cache file does not exist
unless File.exist?(Cache_file)
# If cache is being built
# Check if cache is being built
require 'open3'

if Open3.capture2('ps', 'A').first.split("\n").any? { |l| l.match(/ruby.*Alfred.*rebuild_cache/) }
Expand Down
2 changes: 1 addition & 1 deletion Workflow/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ The Workflow Environment Variables have defaults which will work for most. You o
<string>50</string>
</dict>
<key>version</key>
<string>2022.4</string>
<string>2022.5</string>
<key>webaddress</key>
<string>https://github.com/alfredapp/google-drive-workflow/</string>
</dict>
Expand Down
4 changes: 2 additions & 2 deletions Workflow/rebuild_cache
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# frozen_string_literal: true

require 'json'
require 'pathname'
require 'open3'
require 'pathname'
require 'sqlite3'

Gdrive_paths = if ENV['google_drive_path'].nil? || ENV['google_drive_path'].empty?
Expand All @@ -24,7 +24,7 @@ Cache_file.dirname.mkpath

# If cache is being built
if Open3.capture2('ps', 'A').first.split("\n")
.reject { |l| l.start_with?(Process.pid.to_s) } # Ignore self
.reject { |l| l.start_with?(/\s*#{Process.pid}/) } # Ignore self
.any? { |l| l.match(/ruby.*Alfred.*rebuild_cache/) }
# Ignore scheduled rebuild if another rebuild is in progress
exit 0 if ENV['scheduled_run'] == 'true'
Expand Down

0 comments on commit 1aebe80

Please sign in to comment.