aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service/avatar_storage.vala
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2017-03-12 13:19:04 +0100
committerMarvin W <git@larma.de>2017-03-12 14:09:32 +0100
commite8f11178ecc1a333976ba713f532fcae11931b16 (patch)
tree71ef4de63e27203780f3d5bfaa1662d97faaca16 /libdino/src/service/avatar_storage.vala
parenta9ea0e9f87e71c60bc570066525d3e3634fbdcc0 (diff)
downloaddino-e8f11178ecc1a333976ba713f532fcae11931b16.tar.gz
dino-e8f11178ecc1a333976ba713f532fcae11931b16.zip
Move storage into user directory and fix plugin search path
Diffstat (limited to 'libdino/src/service/avatar_storage.vala')
-rw-r--r--libdino/src/service/avatar_storage.vala17
1 files changed, 11 insertions, 6 deletions
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;
}