-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copy, move and delete thumbnails #29
base: master
Are you sure you want to change the base?
Changes from 2 commits
f292871
afb17c5
8f12a22
2175da2
1f6d769
9ba7da5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
#include <unistd.h> | ||
#include "fm-utils.h" | ||
#include <glib/gi18n-lib.h> | ||
#include "../base/fm-thumbnail-loader.h" | ||
|
||
static const char query[]= | ||
G_FILE_ATTRIBUTE_STANDARD_TYPE"," | ||
|
@@ -746,6 +747,39 @@ gboolean _fm_file_ops_job_copy_run(FmFileOpsJob* job) | |
g_free(tmp_basename); | ||
if(!_fm_file_ops_job_copy_file(job, src, NULL, dest, NULL, df)) | ||
ret = FALSE; | ||
|
||
/* copy thumbnails, if existing */ | ||
if(ret == TRUE && g_file_is_native(src) && g_file_is_native(dest)) | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would consider to honor "thumbnail_local" configuration variable in regards of decision if we have to create a copy for a file thumbnail. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, done |
||
gchar* thumb_dir = g_build_filename(fm_get_home_dir(), thumbnails_path, NULL); | ||
gchar* src_path_normal = g_build_filename(thumb_dir, thumbnails_normal_path, thumbnails_empty_basename, NULL); | ||
gchar* src_path_large = g_build_filename(thumb_dir, thumbnails_large_path, thumbnails_empty_basename, NULL); | ||
gchar* src_uri = g_file_get_uri(src); | ||
gchar* dest_path_normal = g_build_filename(thumb_dir, thumbnails_normal_path, thumbnails_empty_basename, NULL); | ||
gchar* dest_path_large = g_build_filename(thumb_dir, thumbnails_large_path, thumbnails_empty_basename, NULL); | ||
gchar* dest_uri = g_file_get_uri(dest); | ||
ThumbnailTaskFlags flags = LOAD_NORMAL | LOAD_LARGE; | ||
get_thumbnail_paths( src_uri, src_path_normal, src_path_large, flags); | ||
get_thumbnail_paths( dest_uri, dest_path_normal, dest_path_large, flags); | ||
GFile* src_normal = g_file_new_for_path(src_path_normal); | ||
GFile* src_large = g_file_new_for_path(src_path_large); | ||
GFile* dest_normal = g_file_new_for_path(dest_path_normal); | ||
GFile* dest_large = g_file_new_for_path(dest_path_large); | ||
g_file_copy (src_normal, dest_normal, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, NULL); | ||
g_file_copy (src_large, dest_large, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, NULL); | ||
g_free(thumb_dir); | ||
g_free(src_path_normal); | ||
g_free(src_path_large); | ||
g_free(src_uri); | ||
g_free(dest_path_normal); | ||
g_free(dest_path_large); | ||
g_free(dest_uri); | ||
g_object_unref(src_normal); | ||
g_object_unref(src_large); | ||
g_object_unref(dest_normal); | ||
g_object_unref(dest_large); | ||
} | ||
|
||
g_object_unref(src); | ||
g_object_unref(dest); | ||
} | ||
|
@@ -870,6 +904,39 @@ gboolean _fm_file_ops_job_move_run(FmFileOpsJob* job) | |
|
||
if(!_fm_file_ops_job_move_file(job, src, NULL, dest, path, sf, df)) | ||
ret = FALSE; | ||
|
||
/* move thumbnails, if existing */ | ||
if(ret == TRUE && g_file_is_native(src) && g_file_is_native(dest)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about to delete thumbnail if destination file isn't native? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok for me. Done |
||
{ | ||
gchar* thumb_dir = g_build_filename(fm_get_home_dir(), thumbnails_path, NULL); | ||
gchar* src_path_normal = g_build_filename(thumb_dir, thumbnails_normal_path, thumbnails_empty_basename, NULL); | ||
gchar* src_path_large = g_build_filename(thumb_dir, thumbnails_large_path, thumbnails_empty_basename, NULL); | ||
gchar* src_uri = g_file_get_uri(src); | ||
gchar* dest_path_normal = g_build_filename(thumb_dir, thumbnails_normal_path, thumbnails_empty_basename, NULL); | ||
gchar* dest_path_large = g_build_filename(thumb_dir, thumbnails_large_path, thumbnails_empty_basename, NULL); | ||
gchar* dest_uri = g_file_get_uri(dest); | ||
ThumbnailTaskFlags flags = LOAD_NORMAL | LOAD_LARGE; | ||
get_thumbnail_paths( src_uri, src_path_normal, src_path_large, flags); | ||
get_thumbnail_paths( dest_uri, dest_path_normal, dest_path_large, flags); | ||
GFile* src_normal = g_file_new_for_path(src_path_normal); | ||
GFile* src_large = g_file_new_for_path(src_path_large); | ||
GFile* dest_normal = g_file_new_for_path(dest_path_normal); | ||
GFile* dest_large = g_file_new_for_path(dest_path_large); | ||
g_file_move (src_normal, dest_normal, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, NULL); | ||
g_file_move (src_large, dest_large, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, NULL); | ||
g_free(thumb_dir); | ||
g_free(src_path_normal); | ||
g_free(src_path_large); | ||
g_free(src_uri); | ||
g_free(dest_path_normal); | ||
g_free(dest_path_large); | ||
g_free(dest_uri); | ||
g_object_unref(src_normal); | ||
g_object_unref(src_large); | ||
g_object_unref(dest_normal); | ||
g_object_unref(dest_large); | ||
} | ||
|
||
g_object_unref(src); | ||
g_object_unref(dest); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose this should be not copying operation but moving one instead. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, it's fixed now