diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-03-22 06:40:44 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-03-22 06:40:44 +0100 |
commit | 8e1c5a834469d804d28ee8ab2cbe2da8e600a789 (patch) | |
tree | b9771456583eaead893cfd8f02e680b58a3da970 /src/camera/GPhoto.vala | |
parent | 80a5f2d8b095e895a5424f90b2ce4684d94c1a32 (diff) | |
parent | 3253d99365813f2d2ffd05e10cbb8c11f53d746e (diff) |
Merge tag 'upstream/0.26.0'
Upstream version 0.26.0
Diffstat (limited to 'src/camera/GPhoto.vala')
-rw-r--r-- | src/camera/GPhoto.vala | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/camera/GPhoto.vala b/src/camera/GPhoto.vala index 3616cb2..5acc4a3 100644 --- a/src/camera/GPhoto.vala +++ b/src/camera/GPhoto.vala @@ -196,22 +196,27 @@ namespace GPhoto { return new Gdk.Pixbuf.from_stream(ins, null); } - public void save_image(Context context, Camera camera, string folder, string filename, - File dest_file) throws Error { + public void save_image(Context context, Camera camera, string folder, string filename, File dest_file) throws Error { + var fd = Posix.creat(dest_file.get_path(), 0640); + if (fd < 0) { + throw new IOError.FAILED("[%d] Error creating file %s: %m", GLib.errno, dest_file.get_path()); + } + GPhoto.CameraFile camera_file; - GPhoto.Result res = GPhoto.CameraFile.create(out camera_file); - if (res != Result.OK) + GPhoto.Result res = GPhoto.CameraFile.create_from_fd(out camera_file, fd); + if (res != Result.OK) { + Posix.close(fd); throw new GPhotoError.LIBRARY("[%d] Error allocating camera file: %s", (int) res, res.as_string()); + } res = camera.get_file(folder, filename, GPhoto.CameraFileType.NORMAL, camera_file, context); - if (res != Result.OK) + if (res != Result.OK) { + Posix.close(fd); throw new GPhotoError.LIBRARY("[%d] Error retrieving file object for %s/%s: %s", (int) res, folder, filename, res.as_string()); + } - res = camera_file.save(dest_file.get_path()); - if (res != Result.OK) - throw new GPhotoError.LIBRARY("[%d] Error copying file %s/%s to %s: %s", (int) res, - folder, filename, dest_file.get_path(), res.as_string()); + Posix.close(fd); } public PhotoMetadata? load_metadata(Context context, Camera camera, string folder, string filename) |