dropbox-folder-sync 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,4 +2,8 @@
2
2
  # -*- coding: utf-8 -*-
3
3
  $:.unshift(File.expand_path(File.join(File.dirname(__FILE__),'..','lib')))
4
4
  require 'dropbox-folder-sync'
5
- DropboxFolderSync::CLI.start
5
+ begin
6
+ DropboxFolderSync::CLI.start
7
+ rescue => e
8
+ puts e.message
9
+ end
@@ -25,21 +25,39 @@ class DropboxFolderSync::App
25
25
  return true if @session.authorized?
26
26
  end
27
27
 
28
+ req_key = Keystorage.get("DROPBOX_APP_"+APP_KEY+"_REQ_KEY",name)
29
+ req_secret = Keystorage.get("DROPBOX_APP_"+APP_KEY+"_REQ_SECRET",name)
30
+ if req_key and req_secret
31
+ @session.set_request_token(req_key,req_secret)
32
+ @session.get_access_token rescue {}
33
+ if @session.authorized?
34
+ Keystorage.set("DROPBOX_APP_"+APP_KEY+"_USER_KEY",name,@session.access_token.key.to_s)
35
+ Keystorage.set("DROPBOX_APP_"+APP_KEY+"_USER_SECRET",name,@session.access_token.secret.to_s)
36
+ Keystorage.delete("DROPBOX_APP_"+APP_KEY+"_REQ_KEY",name)
37
+ Keystorage.delete("DROPBOX_APP_"+APP_KEY+"_REQ_SECRET",name)
38
+ return true
39
+ end
40
+ end
41
+
42
+
28
43
  @session.get_request_token
29
44
  authorize_url = @session.get_authorize_url
30
- puts "Login: [#{name}] ---> #{authorize_url}"
45
+ log "Login: [#{name}] ---> #{authorize_url}"
31
46
  Launchy.open authorize_url
32
- while 1
33
- @session.get_access_token rescue {}
34
- break if @session.authorized?
35
- sleep 1
36
- end
37
- Keystorage.set("DROPBOX_APP_"+APP_KEY+"_USER_KEY",name,@session.access_token.key.to_s)
38
- Keystorage.set("DROPBOX_APP_"+APP_KEY+"_USER_SECRET",name,@session.access_token.secret.to_s)
39
- true
47
+ Keystorage.set("DROPBOX_APP_"+APP_KEY+"_REQ_KEY",name,@session.request_token.key.to_s)
48
+ Keystorage.set("DROPBOX_APP_"+APP_KEY+"_REQ_SECRET",name,@session.request_token.secret.to_s)
49
+
50
+ #while 1
51
+ # @session.get_access_token rescue {}
52
+ # break if @session.authorized?
53
+ # sleep 1
54
+ #end
55
+ #true
40
56
  end
41
57
 
42
58
  def logout name
59
+ Keystorage.delete("DROPBOX_APP_"+APP_KEY+"_REQ_KEY",name)
60
+ Keystorage.delete("DROPBOX_APP_"+APP_KEY+"_REQ_SECRET",name)
43
61
  Keystorage.delete("DROPBOX_APP_"+APP_KEY+"_USER_KEY",name)
44
62
  Keystorage.delete("DROPBOX_APP_"+APP_KEY+"_USER_SECRET",name)
45
63
  true
@@ -142,6 +160,8 @@ class DropboxFolderSync::App
142
160
  name,@remote_root = parse_remote(remote)
143
161
  @local_root = path_normalize(File.expand_path(local))
144
162
  login(name) unless @session.authorized?
163
+ raise "login before sync" unless @session.authorized?
164
+
145
165
  @client = DropboxClient.new(@session, :dropbox)
146
166
  log "#{@remote_root} <---> #{@local_root}"
147
167
  @local_files = {}
@@ -1,3 +1,3 @@
1
1
  module DropboxFolderSync
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dropbox-folder-sync
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Yoshihiro TAKAHARA