Method: CloudFS::Item#save

Defined in:
lib/cloudfs/item.rb

#save(version_conflict: 'FAIL') ⇒ Item

Save this item's current state. Locally changed properties are committed to this item in user's account

RestAdapter::Errors::OperationNotAllowedError]

Parameters:

  • version_conflict (String) (defaults to: 'FAIL')

    ('FAIL', 'IGNORE') action to take if the version on this item does not match the version on the server

Returns:

  • (Item)

    returns self

Raises:



544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
# File 'lib/cloudfs/item.rb', line 544

def save(version_conflict: 'FAIL')
  FileSystemCommon.validate_item_state(self)
  return self if RestAdapter::Utils.is_blank?(@changed_properties)

  if @type == 'folder'
    response = @rest_adapter.alter_folder_meta(
        @url,
        @version,
        version_conflict: version_conflict,
        ** @changed_properties)
  else
    response = @rest_adapter.alter_file_meta(
        @url,
        @version,
        version_conflict: version_conflict,
        ** @changed_properties)
  end

  parent_url = ::File.dirname(@url)
  set_item_properties(parent: parent_url, ** response)
  self
end