Method: CloudFS::Item#restore
- Defined in:
- lib/cloudfs/item.rb
#restore(destination, method: 'FAIL', restore_argument: nil, raise_exception: false) ⇒ Boolean
Note:
This item's properties are updated if successful
Note:
exist: 'RECREATE' with named path is expensive operation as items in named path hierarchy are traversed in order to fetch Restored item's properties.
Restore this item from trash
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 |
# File 'lib/cloudfs/item.rb', line 473
def restore(destination, method: 'FAIL', restore_argument: nil, raise_exception: false) # restore argument.
fail RestAdapter::Errors::OperationNotAllowedError,
'Item needs to be in trash for Restore operation' unless @in_trash
FileSystemCommon.validate_item_state(destination)
destination_url = FileSystemCommon.get_folder_url(destination)
@rest_adapter.recover_trash_item(
@url,
destination: destination_url,
restore: method)
if restore_argument
set_restored_item_properties(destination_url, method)
end
true
rescue RestAdapter::Errors::SessionNotLinked, RestAdapter::Errors::ServiceError,
RestAdapter::Errors::ArgumentError, RestAdapter::Errors::InvalidItemError,
RestAdapter::Errors::OperationNotAllowedError
raise $! if raise_exception
false
end
|