Class: Dbox::DB::DropboxFile

Inherits:
DropboxBlob show all
Defined in:
lib/dbox/db.rb

Instance Attribute Summary

Attributes inherited from DropboxBlob

#modified_at, #path, #revision

Instance Method Summary collapse

Methods inherited from DropboxBlob

#api, #create, #delete, #force_metadata_update_from_server, #initialize, #local_path, #modified?, #parse_time, #remote_path, #saving_parent_timestamp, #smart_new, #time_to_s, #update, #update_file_timestamp, #update_modification_info

Methods included from Loggable

included, #log

Constructor Details

This class inherits a constructor from Dbox::DB::DropboxBlob

Instance Method Details

#create_localObject



481
482
483
484
485
# File 'lib/dbox/db.rb', line 481

def create_local
  saving_parent_timestamp do
    download
  end
end

#create_remoteObject



498
499
500
# File 'lib/dbox/db.rb', line 498

def create_remote
  upload
end

#delete_localObject



487
488
489
490
491
492
# File 'lib/dbox/db.rb', line 487

def delete_local
  log.info "Deleting file: #{local_path}"
  saving_parent_timestamp do
    FileUtils.rm_rf(local_path)
  end
end

#delete_remoteObject



502
503
504
# File 'lib/dbox/db.rb', line 502

def delete_remote
  api.delete_file(remote_path)
end

#dir?Boolean

Returns:

  • (Boolean)


477
478
479
# File 'lib/dbox/db.rb', line 477

def dir?
  false
end

#downloadObject



510
511
512
513
514
515
516
517
# File 'lib/dbox/db.rb', line 510

def download
  res = api.get_file(remote_path)

  File.open(local_path, "w") do |f|
    f << res
  end
  update_file_timestamp
end

#update_localObject



494
495
496
# File 'lib/dbox/db.rb', line 494

def update_local
  download
end

#update_remoteObject



506
507
508
# File 'lib/dbox/db.rb', line 506

def update_remote
  upload
end

#uploadObject



519
520
521
522
# File 'lib/dbox/db.rb', line 519

def upload
  api.put_file(remote_path, local_path)
  
end