~jeremywootten/pantheon-files/fix-hang-on-large-copy

« back to all changes in this revision

Viewing changes to libcore/gof-file.c

  • Committer: Jeremy Wootten
  • Date: 2016-11-13 14:53:43 UTC
  • mfrom: (2367.1.10 pantheon-files)
  • Revision ID: jeremy@elementaryos.org-20161113145343-3wt1dmlgtbxe11zm
Merge trunk to r2377

Show diffs side-by-side

added added

removed removed

Lines of Context:
583
583
 
584
584
    if (g_file_info_has_attribute (file->info, G_FILE_ATTRIBUTE_UNIX_UID)) {
585
585
        file->uid = g_file_info_get_attribute_uint32 (file->info, G_FILE_ATTRIBUTE_UNIX_UID);
586
 
        if (file->owner == NULL)
 
586
        if (file->owner == NULL) {
587
587
            file->owner = g_strdup_printf ("%d", file->uid);
 
588
        }
 
589
    } else if (file->owner != NULL) { /* e.g. ftp info yields owner but not uid */
 
590
        file->uid = atoi (file->owner);
588
591
    }
589
592
 
590
593
    if (g_file_info_has_attribute (file->info, G_FILE_ATTRIBUTE_UNIX_GID)) {
591
594
        file->gid = g_file_info_get_attribute_uint32 (file->info, G_FILE_ATTRIBUTE_UNIX_GID);
592
 
        if (file->group == NULL)
 
595
        if (file->group == NULL) {
593
596
            file->group = g_strdup_printf ("%d", file->gid);
 
597
        }
 
598
    } else if (file->group != NULL) {  /* e.g. ftp info yields owner but not uid */
 
599
        file->gid = atoi (file->group);
594
600
    }
595
601
 
596
602
    if (g_file_info_has_attribute (file->info, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT))
1344
1350
gof_file_is_writable (GOFFile *file)
1345
1351
{
1346
1352
    g_return_val_if_fail (GOF_IS_FILE (file), FALSE);
1347
 
 
1348
1353
    if (file->target_gof && !g_file_equal (file->location, file->target_gof->location)) {
1349
1354
        return gof_file_is_writable (file->target_gof);
1350
1355
    } else if (file->info != NULL && g_file_info_has_attribute (file->info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)) {
1351
1356
        return g_file_info_get_attribute_boolean (file->info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
1352
1357
    } else if (file->has_permissions) {
1353
 
        return (file->permissions & S_IWOTH) ||
1354
 
               (file->permissions & S_IWUSR) && (strcmp (file->owner, g_get_user_name ()) == 0) ||
1355
 
               (file->permissions & S_IWGRP) && eel_user_in_group (file->group);
 
1358
        return ((file->permissions & S_IWOTH) > 0) ||
 
1359
               ((file->permissions & S_IWUSR) > 0) && (file->uid < 0 || file->uid == geteuid ()) ||
 
1360
               ((file->permissions & S_IWGRP) > 0) && eel_user_in_group (file->group);
1356
1361
    } else {
1357
1362
        return TRUE;  /* We will just have to assume we can write to the file */
1358
1363
    }
1377
1382
        return g_file_info_get_attribute_boolean (file->info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ);
1378
1383
    } else if (file->has_permissions) {
1379
1384
        return (file->permissions & S_IROTH) ||
1380
 
               (file->permissions & S_IRUSR) && (strcmp (file->owner, g_get_user_name ()) == 0) ||
 
1385
               (file->permissions & S_IRUSR) && (file->uid < 0 || file->uid == geteuid ()) ||
1381
1386
               (file->permissions & S_IRGRP) && eel_user_in_group (file->group);
1382
1387
    } else {
1383
1388
        return TRUE;  /* We will just have to assume we can read the file */
1419
1424
    g_return_val_if_fail (file != NULL, NULL);
1420
1425
    g_return_val_if_fail (file->info != NULL, NULL);
1421
1426
 
1422
 
    guint64 date = g_file_info_get_attribute_uint64 (file->info, attr);
1423
 
    if (date == 0)
1424
 
        return NULL;
1425
 
 
1426
 
    return eel_get_date_as_string (date, gof_preferences_get_default ()->pref_date_format);
 
1427
    return pf_file_utils_get_formatted_time_attribute_from_info (file->info,
 
1428
                                                                 attr,
 
1429
                                                                 gof_preferences_get_default ()->pref_date_format);
1427
1430
}
1428
1431
 
1429
1432
 
1756
1759
                return 0;
1757
1760
        }
1758
1761
 
1759
 
        /* if the source offers both copy and move and the GTK+ suggested action is copy, try to be smart telling whether we should copy or move by default by checking whether the source and target are on the same disk. */
 
1762
        /* if the source offers both copy and move and the GTK+ suggested action is copy, try to
 
1763
         * be smart telling whether we should copy or move by default by checking whether the
 
1764
         * source and target are on the same disk. */
1760
1765
        if ((actions & (GDK_ACTION_COPY | GDK_ACTION_MOVE)) != 0
1761
1766
            && (suggested_action == GDK_ACTION_COPY))
1762
1767
        {
1779
1784
                if (ofile == NULL
1780
1785
                    || !gof_file_same_filesystem (file, ofile)
1781
1786
                    || (ofile->info != NULL
1782
 
                        && g_file_info_get_attribute_uint32 (ofile->info,
1783
 
                                                             G_FILE_ATTRIBUTE_UNIX_UID) != effective_user_id))
 
1787
                        && ofile->uid > -1
 
1788
                        && ofile->uid != effective_user_id ))
1784
1789
                {
1785
1790
                    /* default to copy and get outa here */
1786
1791
                    suggested_action = GDK_ACTION_COPY;