From e8f11178ecc1a333976ba713f532fcae11931b16 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sun, 12 Mar 2017 13:19:04 +0100 Subject: Move storage into user directory and fix plugin search path --- libdino/src/service/avatar_storage.vala | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'libdino/src/service/avatar_storage.vala') diff --git a/libdino/src/service/avatar_storage.vala b/libdino/src/service/avatar_storage.vala index a9a8fb86..46b43d99 100644 --- a/libdino/src/service/avatar_storage.vala +++ b/libdino/src/service/avatar_storage.vala @@ -9,23 +9,28 @@ public class AvatarStorage : Xep.PixbufStorage, Object { public AvatarStorage(string folder) { this.folder = folder; + DirUtils.create_with_parents(folder, 0700); } public void store(string id, uint8[] data) { - File file = File.new_for_path(id); - if (file.query_exists()) file.delete(); //TODO y? - DataOutputStream fos = new DataOutputStream(file.create(FileCreateFlags.REPLACE_DESTINATION)); - fos.write(data); + File file = File.new_for_path(Path.build_filename(folder, id)); + try { + if (file.query_exists()) file.delete(); //TODO y? + DataOutputStream fos = new DataOutputStream(file.create(FileCreateFlags.REPLACE_DESTINATION)); + fos.write(data); + } catch (Error e) { + // Ignore: we failed in storing, so we refuse to display later... + } } public bool has_image(string id) { - File file = File.new_for_path(folder + id); + File file = File.new_for_path(Path.build_filename(folder, id)); return file.query_exists(); } public Pixbuf? get_image(string id) { try { - return new Pixbuf.from_file(folder + id); + return new Pixbuf.from_file(Path.build_filename(folder, id)); } catch (Error e) { return null; } -- cgit v1.2.3-54-g00ecf