Skip to content

Commit 192451f

Browse files
samertmraveit65
authored andcommitted
Validate that Dropbox runs after downloading it
Validate that Dropbox can run by running `dropboxd /testrun 0`. Show an error message that points users to the system requirements help page if it won't run. origin commit: dropbox/nautilus-dropbox@ff410cd
1 parent 3d511a6 commit 192451f

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

caja-dropbox.in

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ WARNING = u"In order to use Dropbox, you must download the proprietary daemon."
5959
GPG_WARNING = u"Note: python-gpg (python-gpgme for Ubuntu 17.04 and lower) is not installed, we will not be able to verify binary signatures."
6060
ERROR_CONNECTING = u"Trouble connecting to Dropbox servers. Maybe your internet connection is down, or you need to set your http_proxy environment variable."
6161
ERROR_SIGNATURE = u"Downloaded binary does not match Dropbox signature, aborting install."
62+
ERROR_INVALID_DROPBOX = u"Could not run Dropbox. Make sure your computer meets the minimum requirements:\nhttps://www.dropbox.com/help/desktop-web/system-requirements#desktop"
6263

6364
DOWNLOAD_LOCATION_FMT = "https://www.dropbox.com/download?plat=%s"
6465
SIGNATURE_LOCATION_FMT = "https://www.dropbox.com/download?plat=%s&signature=1"
@@ -288,6 +289,35 @@ class DownloadState(object):
288289
if not self.local_file.closed:
289290
self.local_file.close()
290291

292+
def is_dropbox_valid(self):
293+
"""
294+
Validate that Dropbox runs, so we can show an error
295+
message to the user if it doesn't work.
296+
297+
Returns True if Dropbox can run, false otherwise.
298+
"""
299+
db_path = DROPBOXD_PATH.encode(sys.getfilesystemencoding())
300+
f = open("/dev/null", "w")
301+
try:
302+
a = subprocess.Popen([db_path, "/testrun", "0"], preexec_fn=os.setsid, cwd=os.path.expanduser("~"),
303+
stderr=sys.stderr, stdout=f, close_fds=True)
304+
except Exception, ex:
305+
print ex
306+
return False
307+
308+
# in seconds
309+
interval = 0.5
310+
wait_for = 30
311+
for i in xrange(int(wait_for / interval)):
312+
ret_val = a.poll()
313+
if ret_val is None:
314+
time.sleep(interval)
315+
continue
316+
return ret_val == 0
317+
318+
return False
319+
320+
291321
def load_serialized_images():
292322
global box_logo_pixbuf, window_icon
293323
import gtk
@@ -408,6 +438,8 @@ if GUI_AVAILABLE:
408438

409439
def finished():
410440
self.update_progress(UNPACKING, 1.0)
441+
if not self.download.is_dropbox_valid():
442+
FatalVisibleError(ERROR_INVALID_DROPBOX)
411443
gtk.main_quit()
412444

413445
def error(ex):
@@ -592,6 +624,9 @@ else:
592624
else:
593625
setprogress(UNPACKING, 1.0)
594626

627+
if not download.is_dropbox_valid():
628+
FatalVisibleError(ERROR_INVALID_DROPBOX)
629+
595630
console_print()
596631

597632
class CommandTicker(threading.Thread):

0 commit comments

Comments
 (0)