{"action":"created","comment":{"url":"https://api.github.com/repos/geany/geany/pulls/comments/40621975","id":40621975,"diff_hunk":"@@ -930,36 +930,89 @@ typedef struct\n } FileData;\n \n \n+static time_t get_mtime(const gchar *locale_filename)\n+{\n+\tGError *error = NULL;\n+\tconst gchar *err_msg = NULL;\n+\ttime_t time = 0;\n+\n+\tif (!file_prefs.use_safe_file_saving && file_prefs.use_gio_unsafe_file_saving)\n+\t{\n+\t\tGFile *file = g_file_new_for_path(locale_filename);\n+\t\tGFileInfo *info = g_file_query_info(file, G_FILE_ATTRIBUTE_TIME_MODIFIED, G_FILE_QUERY_INFO_NONE, NULL, &error);\n+\n+\t\tif (info)\n+\t\t{\n+\t\t\tGTimeVal timeval;\n+\n+\t\t\tg_file_info_get_modification_time(info, &timeval);\n+\t\t\tg_object_unref(info);\n+\t\t\ttime = timeval.tv_sec;\n+\t\t}\n+\t\telse if (error)\n+\t\t\terr_msg = error->message;\n+\n+\t\tg_object_unref(file);\n+\t}\n+\telse\n+\t{\n+\t\tstruct stat st;\n+\n+\t\tif (g_stat(locale_filename, &st) == 0)\n+\t\t\ttime = st.st_mtime;\n+\t\telse\n+\t\t\terr_msg = g_strerror(errno);\n+\t}\n+\n+\tif (err_msg)\n+\t{\n+\t\tgchar *utf8_filename = utils_get_utf8_from_locale(locale_filename);\n+\n+\t\tui_set_statusbar(TRUE, _(\"Could not open file %s (%s)\"),\n+\t\t\tutf8_filename, err_msg);\n+\t\tg_free(utf8_filename);\n+\t}\n+\n+\tif (error)\n+\t\tg_error_free(error);\n+\n+\treturn time;\n+}\n+\n+\n /* loads textfile data, verifies and converts to forced_enc or UTF-8. Also handles BOM. */\n static gboolean load_text_file(const gchar *locale_filename, const gchar *display_filename,\n \tFileData *filedata, const gchar *forced_enc)\n {\n \tGError *err = NULL;\n-\tstruct stat st;\n \n \tfiledata->data = NULL;\n \tfiledata->len = 0;\n \tfiledata->enc = NULL;\n \tfiledata->bom = FALSE;\n \tfiledata->readonly = FALSE;\n+\tfiledata->mtime = get_mtime(locale_filename);\n \n-\tif (g_stat(locale_filename, &st) != 0)\n-\t{\n-\t\tui_set_statusbar(TRUE, _(\"Could not open file %s (%s)\"),\n-\t\t\tdisplay_filename, g_strerror(errno));\n+\tif (filedata->mtime == 0)\n \t\treturn FALSE;\n-\t}\n \n-\tfiledata->mtime = st.st_mtime;\n+\tif (!file_prefs.use_safe_file_saving && file_prefs.use_gio_unsafe_file_saving)\n+\t{\n+\t\tGFile *file = g_file_new_for_path(locale_filename);\n+\n+\t\tg_file_load_contents(file, NULL, &filedata->data, &filedata->len, NULL, &err);\n+\t\tg_object_unref(file);\n+\t}\n+\telse\n+\t\tg_file_get_contents(locale_filename, &filedata->data, &filedata->len, &err);\n \n-\tif (! g_file_get_contents(locale_filename, &filedata->data, NULL, &err))\n+\tif (err)\n \t{\n \t\tui_set_statusbar(TRUE, \"%s\", err->message);\n \t\tg_error_free(err);\n \t\treturn FALSE;\n \t}\n \n-\tfiledata->len = (gsize) st.st_size;","path":"src/document.c","position":113,"original_position":104,"commit_id":"2693eb451098d7df74e31108c9f07b8350580990","original_commit_id":"12899d1286113ac89b50e406354d7b51c236acbe","user":{"login":"elextr","id":811085,"avatar_url":"https://avatars.githubusercontent.com/u/811085?v=3","gravatar_id":"","url":"https://api.github.com/users/elextr","html_url":"https://github.com/elextr","followers_url":"https://api.github.com/users/elextr/followers","following_url":"https://api.github.com/users/elextr/following{/other_user}","gists_url":"https://api.github.com/users/elextr/gists{/gist_id}","starred_url":"https://api.github.com/users/elextr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elextr/subscriptions","organizations_url":"https://api.github.com/users/elextr/orgs","repos_url":"https://api.github.com/users/elextr/repos","events_url":"https://api.github.com/users/elextr/events{/privacy}","received_events_url":"https://api.github.com/users/elextr/received_events","type":"User","site_admin":false},"body":"@techee, the `stat` is done here (well just above) so we have the size, so unless something else does another `stat` it needs to be passed to `handle_buffer()` to compare to the `strlen()`.\r\n\r\n`encodings_convert_to_utf8_auto()` therefore expects the buffer length here and passes back the modified length after converting the encoding.\r\n\r\nFor that purpose it doesn't matter if you use the `stat` value or the `*_contents()` value, since if they are different there has been a read error.\r\n\r\nSo I would just use the buffer size returned by Glib/GIO since it is a more direct measure of the buffer size.","created_at":"2015-09-29T00:15:49Z","updated_at":"2015-09-29T00:15:49Z","html_url":"https://github.com/geany/geany/pull/621#discussion_r40621975","pull_request_url":"https://api.github.com/repos/geany/geany/pulls/621","_links":{"self":{"href":"https://api.github.com/repos/geany/geany/pulls/comments/40621975"},"html":{"href":"https://github.com/geany/geany/pull/621#discussion_r40621975"},"pull_request":{"href":"https://api.github.com/repos/geany/geany/pulls/621"}}},"pull_request":{"url":"https://api.github.com/repos/geany/geany/pulls/621","id":43083611,"html_url":"https://github.com/geany/geany/pull/621","diff_url":"https://github.com/geany/geany/pull/621.diff","patch_url":"https://github.com/geany/geany/pull/621.patch","issue_url":"https://api.github.com/repos/geany/geany/issues/621","number":621,"state":"open","locked":false,"title":"Fix the \"source file has been modified\" issue","user":{"login":"techee","id":713965,"avatar_url":"https://avatars.githubusercontent.com/u/713965?v=3","gravatar_id":"","url":"https://api.github.com/users/techee","html_url":"https://github.com/techee","followers_url":"https://api.github.com/users/techee/followers","following_url":"https://api.github.com/users/techee/following{/other_user}","gists_url":"https://api.github.com/users/techee/gists{/gist_id}","starred_url":"https://api.github.com/users/techee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/techee/subscriptions","organizations_url":"https://api.github.com/users/techee/orgs","repos_url":"https://api.github.com/users/techee/repos","events_url":"https://api.github.com/users/techee/events{/privacy}","received_events_url":"https://api.github.com/users/techee/received_events","type":"User","site_admin":false},"body":"This is the fix I proposed in #605. Meanwhile I have been able to reproduce the issue (simply by using GVFS over ssh to a remote server on Ubuntu) and it indeed seems to fix the issue.","created_at":"2015-08-21T21:36:20Z","updated_at":"2015-09-29T00:15:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"65e8dff61b00d4e99d3d24efc943a2c64633a69a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/geany/geany/pulls/621/commits","review_comments_url":"https://api.github.com/repos/geany/geany/pulls/621/comments","review_comment_url":"https://api.github.com/repos/geany/geany/pulls/comments{/number}","comments_url":"https://api.github.com/repos/geany/geany/issues/621/comments","statuses_url":"https://api.github.com/repos/geany/geany/statuses/2693eb451098d7df74e31108c9f07b8350580990","head":{"label":"techee:remote_mtime","ref":"remote_mtime","sha":"2693eb451098d7df74e31108c9f07b8350580990","user":{"login":"techee","id":713965,"avatar_url":"https://avatars.githubusercontent.com/u/713965?v=3","gravatar_id":"","url":"https://api.github.com/users/techee","html_url":"https://github.com/techee","followers_url":"https://api.github.com/users/techee/followers","following_url":"https://api.github.com/users/techee/following{/other_user}","gists_url":"https://api.github.com/users/techee/gists{/gist_id}","starred_url":"https://api.github.com/users/techee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/techee/subscriptions","organizations_url":"https://api.github.com/users/techee/orgs","repos_url":"https://api.github.com/users/techee/repos","events_url":"https://api.github.com/users/techee/events{/privacy}","received_events_url":"https://api.github.com/users/techee/received_events","type":"User","site_admin":false},"repo":{"id":24825705,"name":"geany","full_name":"techee/geany","owner":{"login":"techee","id":713965,"avatar_url":"https://avatars.githubusercontent.com/u/713965?v=3","gravatar_id":"","url":"https://api.github.com/users/techee","html_url":"https://github.com/techee","followers_url":"https://api.github.com/users/techee/followers","following_url":"https://api.github.com/users/techee/following{/other_user}","gists_url":"https://api.github.com/users/techee/gists{/gist_id}","starred_url":"https://api.github.com/users/techee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/techee/subscriptions","organizations_url":"https://api.github.com/users/techee/orgs","repos_url":"https://api.github.com/users/techee/repos","events_url":"https://api.github.com/users/techee/events{/privacy}","received_events_url":"https://api.github.com/users/techee/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/techee/geany","description":"A fast and lightweight IDE","fork":true,"url":"https://api.github.com/repos/techee/geany","forks_url":"https://api.github.com/repos/techee/geany/forks","keys_url":"https://api.github.com/repos/techee/geany/keys{/key_id}","collaborators_url":"https://api.github.com/repos/techee/geany/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/techee/geany/teams","hooks_url":"https://api.github.com/repos/techee/geany/hooks","issue_events_url":"https://api.github.com/repos/techee/geany/issues/events{/number}","events_url":"https://api.github.com/repos/techee/geany/events","assignees_url":"https://api.github.com/repos/techee/geany/assignees{/user}","branches_url":"https://api.github.com/repos/techee/geany/branches{/branch}","tags_url":"https://api.github.com/repos/techee/geany/tags","blobs_url":"https://api.github.com/repos/techee/geany/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/techee/geany/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/techee/geany/git/refs{/sha}","trees_url":"https://api.github.com/repos/techee/geany/git/trees{/sha}","statuses_url":"https://api.github.com/repos/techee/geany/statuses/{sha}","languages_url":"https://api.github.com/repos/techee/geany/languages","stargazers_url":"https://api.github.com/repos/techee/geany/stargazers","contributors_url":"https://api.github.com/repos/techee/geany/contributors","subscribers_url":"https://api.github.com/repos/techee/geany/subscribers","subscription_url":"https://api.github.com/repos/techee/geany/subscription","commits_url":"https://api.github.com/repos/techee/geany/commits{/sha}","git_commits_url":"https://api.github.com/repos/techee/geany/git/commits{/sha}","comments_url":"https://api.github.com/repos/techee/geany/comments{/number}","issue_comment_url":"https://api.github.com/repos/techee/geany/issues/comments{/number}","contents_url":"https://api.github.com/repos/techee/geany/contents/{+path}","compare_url":"https://api.github.com/repos/techee/geany/compare/{base}...{head}","merges_url":"https://api.github.com/repos/techee/geany/merges","archive_url":"https://api.github.com/repos/techee/geany/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/techee/geany/downloads","issues_url":"https://api.github.com/repos/techee/geany/issues{/number}","pulls_url":"https://api.github.com/repos/techee/geany/pulls{/number}","milestones_url":"https://api.github.com/repos/techee/geany/milestones{/number}","notifications_url":"https://api.github.com/repos/techee/geany/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/techee/geany/labels{/name}","releases_url":"https://api.github.com/repos/techee/geany/releases{/id}","created_at":"2014-10-05T20:38:07Z","updated_at":"2015-03-11T21:37:59Z","pushed_at":"2015-09-26T23:30:32Z","git_url":"git://github.com/techee/geany.git","ssh_url":"git@github.com:techee/geany.git","clone_url":"https://github.com/techee/geany.git","svn_url":"https://github.com/techee/geany","homepage":"http://www.geany.org","size":41305,"stargazers_count":0,"watchers_count":0,"language":"Gettext Catalog","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"geany:master","ref":"master","sha":"31325bb2310f3946668ba420910f0e44a734b0fa","user":{"login":"geany","id":1108795,"avatar_url":"https://avatars.githubusercontent.com/u/1108795?v=3","gravatar_id":"","url":"https://api.github.com/users/geany","html_url":"https://github.com/geany","followers_url":"https://api.github.com/users/geany/followers","following_url":"https://api.github.com/users/geany/following{/other_user}","gists_url":"https://api.github.com/users/geany/gists{/gist_id}","starred_url":"https://api.github.com/users/geany/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geany/subscriptions","organizations_url":"https://api.github.com/users/geany/orgs","repos_url":"https://api.github.com/users/geany/repos","events_url":"https://api.github.com/users/geany/events{/privacy}","received_events_url":"https://api.github.com/users/geany/received_events","type":"Organization","site_admin":false},"repo":{"id":2532922,"name":"geany","full_name":"geany/geany","owner":{"login":"geany","id":1108795,"avatar_url":"https://avatars.githubusercontent.com/u/1108795?v=3","gravatar_id":"","url":"https://api.github.com/users/geany","html_url":"https://github.com/geany","followers_url":"https://api.github.com/users/geany/followers","following_url":"https://api.github.com/users/geany/following{/other_user}","gists_url":"https://api.github.com/users/geany/gists{/gist_id}","starred_url":"https://api.github.com/users/geany/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geany/subscriptions","organizations_url":"https://api.github.com/users/geany/orgs","repos_url":"https://api.github.com/users/geany/repos","events_url":"https://api.github.com/users/geany/events{/privacy}","received_events_url":"https://api.github.com/users/geany/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/geany/geany","description":"A fast and lightweight IDE","fork":false,"url":"https://api.github.com/repos/geany/geany","forks_url":"https://api.github.com/repos/geany/geany/forks","keys_url":"https://api.github.com/repos/geany/geany/keys{/key_id}","collaborators_url":"https://api.github.com/repos/geany/geany/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/geany/geany/teams","hooks_url":"https://api.github.com/repos/geany/geany/hooks","issue_events_url":"https://api.github.com/repos/geany/geany/issues/events{/number}","events_url":"https://api.github.com/repos/geany/geany/events","assignees_url":"https://api.github.com/repos/geany/geany/assignees{/user}","branches_url":"https://api.github.com/repos/geany/geany/branches{/branch}","tags_url":"https://api.github.com/repos/geany/geany/tags","blobs_url":"https://api.github.com/repos/geany/geany/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/geany/geany/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/geany/geany/git/refs{/sha}","trees_url":"https://api.github.com/repos/geany/geany/git/trees{/sha}","statuses_url":"https://api.github.com/repos/geany/geany/statuses/{sha}","languages_url":"https://api.github.com/repos/geany/geany/languages","stargazers_url":"https://api.github.com/repos/geany/geany/stargazers","contributors_url":"https://api.github.com/repos/geany/geany/contributors","subscribers_url":"https://api.github.com/repos/geany/geany/subscribers","subscription_url":"https://api.github.com/repos/geany/geany/subscription","commits_url":"https://api.github.com/repos/geany/geany/commits{/sha}","git_commits_url":"https://api.github.com/repos/geany/geany/git/commits{/sha}","comments_url":"https://api.github.com/repos/geany/geany/comments{/number}","issue_comment_url":"https://api.github.com/repos/geany/geany/issues/comments{/number}","contents_url":"https://api.github.com/repos/geany/geany/contents/{+path}","compare_url":"https://api.github.com/repos/geany/geany/compare/{base}...{head}","merges_url":"https://api.github.com/repos/geany/geany/merges","archive_url":"https://api.github.com/repos/geany/geany/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/geany/geany/downloads","issues_url":"https://api.github.com/repos/geany/geany/issues{/number}","pulls_url":"https://api.github.com/repos/geany/geany/pulls{/number}","milestones_url":"https://api.github.com/repos/geany/geany/milestones{/number}","notifications_url":"https://api.github.com/repos/geany/geany/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/geany/geany/labels{/name}","releases_url":"https://api.github.com/repos/geany/geany/releases{/id}","created_at":"2011-10-07T14:25:32Z","updated_at":"2015-09-28T07:39:58Z","pushed_at":"2015-09-28T15:18:08Z","git_url":"git://github.com/geany/geany.git","ssh_url":"git@github.com:geany/geany.git","clone_url":"https://github.com/geany/geany.git","svn_url":"https://github.com/geany/geany","homepage":"http://www.geany.org","size":50820,"stargazers_count":648,"watchers_count":648,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":238,"mirror_url":null,"open_issues_count":191,"forks":238,"open_issues":191,"watchers":648,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/geany/geany/pulls/621"},"html":{"href":"https://github.com/geany/geany/pull/621"},"issue":{"href":"https://api.github.com/repos/geany/geany/issues/621"},"comments":{"href":"https://api.github.com/repos/geany/geany/issues/621/comments"},"review_comments":{"href":"https://api.github.com/repos/geany/geany/pulls/621/comments"},"review_comment":{"href":"https://api.github.com/repos/geany/geany/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/geany/geany/pulls/621/commits"},"statuses":{"href":"https://api.github.com/repos/geany/geany/statuses/2693eb451098d7df74e31108c9f07b8350580990"}}}}