Permalink
Browse files

Patching around RPC calls to file deletes

If Pro::Client is around, use it for deleting files. Otherwise, try an
unlink directly.
  • Loading branch information...
1 parent 46a69c0 commit 52bcb5b4d9fdefc1d1e72aff70838721656a8c68 @todb todb committed Apr 16, 2012
@@ -13,8 +13,12 @@ def self.included(base)
private
def delete_file
- c = Pro::Client.get
- c.loot_delete_file(self[:id])
+ c = Pro::Client.get rescue nil
+ if c
+ c.loot_delete_file(self[:id])
+ else
+ ::File.unlink(self.path) rescue nil
+ end
end
}
end
@@ -16,8 +16,12 @@ def self.included(base)
private
def delete_file
- c = Pro::Client.get
- c.report_delete_file(self[:id])
+ c = Pro::Client.get rescue nil
+ if c
+ c.report_delete_file(self[:id])
+ else
+ ::File.unlink(self.path) rescue nil
+ end
end
}
end
@@ -9,8 +9,12 @@ def self.included(base)
private
def delete_file
- c = Pro::Client.get
- c.report_template_delete_file(self[:id])
+ c = Pro::Client.get rescue nil
+ if c
+ c.report_template_delete_file(self[:id])
+ else
+ ::File.unlink(self.path) rescue nil
+ end
end
}
end
@@ -18,7 +18,7 @@ def self.included(base)
private
def stop
- c = Pro::Client.get
+ c = Pro::Client.get rescue nil
c.session_stop(self.local_id) rescue nil # ignore exceptions (XXX - ideally, stopped an already-stopped session wouldn't throw XMLRPCException)
end
}
@@ -15,8 +15,12 @@ def self.included(base)
private
def delete_file
- c = Pro::Client.get
- c.task_delete_log(self[:id])
+ c = Pro::Client.get rescue nil
+ if c
+ c.task_delete_log(self[:id]) if c
+ else
+ ::File.unlink(self.path) rescue nil
+ end
end
}
end

0 comments on commit 52bcb5b

Please sign in to comment.