Class: Evesync::Handler::File

Inherits:
Object
  • Object
show all
Defined in:
lib/evesync/handler/file.rb

Instance Method Summary collapse

Instance Method Details

#handle(file) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/evesync/handler/file.rb', line 6

def handle(file)
  Log.debug("Handler File handling started...")
  content = file.content
  name = file.name
  Log.debug("Handler File writing received content to #{name}")

  if file.action == IPC::Data::File::Action::DELETE
    ::File.delete(name)
  else # TODO: handle move_to and move_from
    # TODO: handle exceptions or throw them
    # Writing content
    ::File.write(name, content)
    # Changing mode
    ::File.chmod(name, file.mode)
  end

  # Returning all fine!
  Log.debug("Handler File handling done!")
  true
end