Commit a085188c authored by Pavel Cisler's avatar Pavel Cisler Committed by Pavel Cisler

reviewed by: Darin Adler <darin@eazel.com>

2000-12-12  Pavel Cisler <pavel@eazel.com>

	reviewed by: Darin Adler <darin@eazel.com>

	Fixed 4954 Nautilus crashes attempting to empty a .Trash
	containing undeletable files

	* libnautilus-extensions/nautilus-file-operations.c:
	(build_error_string), (handle_xfer_vfs_error)
	Reworked the error message building logic. Split up
	the routine into a part that decides what the interesting
	input for building the error message is and a part that
	actually builds the error message. Fixed a number
	of cases where a wrong error message would be used. The
	actual bug in the bug report was one of the cases -- an assert
	catching a case that was not handled properly.

	Fixed:
	part of -- 638 When a new volume gets mounted, integrate its Trash
	directory.
	part of -- 4143 Files dragged to trash icon on desktop seem to
	vanish,
	part of -- 4963 Files dragged to Trash from floppy don't appear
	in Trash,

	* libnautilus-extensions/nautilus-trash-monitor.c:
	* libnautilus-extensions/nautilus-trash-monitor.h:
	(add_one_volume_trash),
	(nautilus_trash_monitor_get_trash_directories):
	Added a new call that returns a list of all the Trash directories
	on all the mouted volumes.

	* libnautilus-extensions/nautilus-trash-directory.c: (add_volume):
	Got rid of get_volume_vfs_uri_if_writable.
	Used the new nautilus_volume_monitor_should_integrate_trash instead
	to pick the volumes that can support trash.

	* libnautilus-extensions/nautilus-volume-monitor.c:
	(nautilus_volume_monitor_should_integrate_trash),
	(nautilus_volume_monitor_get_volume_mount_uri):
	* libnautilus-extensions/nautilus-volume-monitor.h:
	Add new helper calls used by the routine that collects all the
	trash uris from all mouted volumes.

	* libnautilus-extensions/nautilus-file-operations.c:
	(do_empty_trash):
	Pass in a list of Trash directories instead of just the
	single trash in the user's home directory.

	Fixed:
	2443 Trash is only found on EXT2 volumes
	2444 Trash on read-only volumes is not displayed
	remaining part of -- 4143 Files dragged to trash icon on desktop
	seem to vanish,
	remaining part of -- 4963 Files dragged to Trash from floppy
	don't appear in Trash,

	* libnautilus-extensions/nautilus-volume-monitor.c:
	(nautilus_volume_monitor_should_integrate_trash):
	Removed the old logic from get_volume_vfs_uri_if_writable
	that only displayed trash from writable ext2 volumes.
	Enumerated all the file system types that we know can
	support trash.
parent e94c8057
2000-12-12 Pavel Cisler <pavel@eazel.com>
reviewed by: Darin Adler <darin@eazel.com>
Fixed 4954 Nautilus crashes attempting to empty a .Trash
containing undeletable files
* libnautilus-extensions/nautilus-file-operations.c:
(build_error_string), (handle_xfer_vfs_error)
Reworked the error message building logic. Split up
the routine into a part that decides what the interesting
input for building the error message is and a part that
actually builds the error message. Fixed a number
of cases where a wrong error message would be used. The
actual bug in the bug report was one of the cases -- an assert
catching a case that was not handled properly.
Fixed:
part of -- 638 When a new volume gets mounted, integrate its Trash
directory.
part of -- 4143 Files dragged to trash icon on desktop seem to
vanish,
part of -- 4963 Files dragged to Trash from floppy don't appear
in Trash,
* libnautilus-extensions/nautilus-trash-monitor.c:
* libnautilus-extensions/nautilus-trash-monitor.h:
(add_one_volume_trash),
(nautilus_trash_monitor_get_trash_directories):
Added a new call that returns a list of all the Trash directories
on all the mouted volumes.
* libnautilus-extensions/nautilus-trash-directory.c: (add_volume):
Got rid of get_volume_vfs_uri_if_writable.
Used the new nautilus_volume_monitor_should_integrate_trash instead
to pick the volumes that can support trash.
* libnautilus-extensions/nautilus-volume-monitor.c:
(nautilus_volume_monitor_should_integrate_trash),
(nautilus_volume_monitor_get_volume_mount_uri):
* libnautilus-extensions/nautilus-volume-monitor.h:
Add new helper calls used by the routine that collects all the
trash uris from all mouted volumes.
* libnautilus-extensions/nautilus-file-operations.c:
(do_empty_trash):
Pass in a list of Trash directories instead of just the
single trash in the user's home directory.
Fixed:
2443 Trash is only found on EXT2 volumes
2444 Trash on read-only volumes is not displayed
remaining part of -- 4143 Files dragged to trash icon on desktop
seem to vanish,
remaining part of -- 4963 Files dragged to Trash from floppy
don't appear in Trash,
* libnautilus-extensions/nautilus-volume-monitor.c:
(nautilus_volume_monitor_should_integrate_trash):
Removed the old logic from get_volume_vfs_uri_if_writable
that only displayed trash from writable ext2 volumes.
Enumerated all the file system types that we know can
support trash.
2000-12-12 Eskil Heyn Olsen <eskil@eazel.com>
* components/services/install/lib/eazel-package-system-private.h:
......@@ -149,7 +213,6 @@
that did a hide followed by a show. Corrected an assert that
should have been a return_if_fail.
>>>>>>> 1.3120
2000-12-12 John Sullivan <sullivan@eazel.com>
reviewed by: Darin Adler <darin@eazel.com>
......
......@@ -55,32 +55,6 @@ NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusTrashDirectory,
nautilus_trash_directory,
NAUTILUS_TYPE_MERGED_DIRECTORY)
static GnomeVFSURI *
get_volume_vfs_uri_if_writable (NautilusVolume *volume)
{
char *uri;
GnomeVFSURI *vfs_uri;
/* FIXME bugzilla.eazel.com 2443:
* Why is trash only found on EXT2 volumes? This seems
* like an incorrect check.
*/
/* FIXME bugzilla.eazel.com 2444:
* Why can't we view the trash on a read-only volume
* if it happens to be there?
*/
if (volume->type != NAUTILUS_VOLUME_EXT2 || volume->is_read_only) {
return NULL;
}
uri = gnome_vfs_get_uri_from_local_path (volume->mount_path);
vfs_uri = gnome_vfs_uri_new (uri);
g_free (uri);
return vfs_uri;
}
static void
find_directory_callback (GnomeVFSAsyncHandle *handle,
GList *results,
......@@ -129,7 +103,7 @@ add_volume (NautilusTrashDirectory *trash,
NautilusVolume *volume)
{
TrashVolume *trash_volume;
GnomeVFSURI *vfs_uri;
GnomeVFSURI *volume_mount_uri;
GList vfs_uri_as_list;
/* Quick out if we already know about this volume. */
......@@ -139,11 +113,12 @@ add_volume (NautilusTrashDirectory *trash,
return;
}
/* If we can't get the URI, we jus don't do trash on this volume. */
vfs_uri = get_volume_vfs_uri_if_writable (volume);
if (vfs_uri == NULL) {
if (!nautilus_volume_monitor_should_integrate_trash (volume)) {
return;
}
volume_mount_uri = gnome_vfs_uri_new (
nautilus_volume_monitor_get_volume_mount_uri (volume));
/* Make the structure used to track the trash for this volume. */
trash_volume = g_new0 (TrashVolume, 1);
......@@ -152,7 +127,7 @@ add_volume (NautilusTrashDirectory *trash,
g_hash_table_insert (trash->details->volumes, volume, trash_volume);
/* Find the real trash directory for this one. */
vfs_uri_as_list.data = vfs_uri;
vfs_uri_as_list.data = volume_mount_uri;
vfs_uri_as_list.next = NULL;
vfs_uri_as_list.prev = NULL;
/* Search for Trash directories but don't create new ones. */
......
......@@ -187,3 +187,57 @@ nautilus_trash_monitor_is_empty (void)
{
return nautilus_trash_monitor_get ()->details->empty;
}
static gboolean
add_one_volume_trash (const NautilusVolume *volume,
gpointer callback_data)
{
GnomeVFSURI *volume_mount_point_uri;
GnomeVFSURI *trash_uri;
GList **result;
result = (GList **)callback_data;
if (nautilus_volume_monitor_should_integrate_trash (volume)) {
/* Get the uri of the volume mount point as the place
* "near" which to look for trash on the given volume.
*/
volume_mount_point_uri = gnome_vfs_uri_new (
nautilus_volume_monitor_get_volume_mount_uri (volume));
g_assert (volume_mount_point_uri != NULL);
/* Look for trash. It is OK to use a sync call here because
* the options we use (don't create, don't look for it if we
* already don't know where it is) do not cause any IO.
*/
if (gnome_vfs_find_directory (volume_mount_point_uri,
GNOME_VFS_DIRECTORY_KIND_TRASH, &trash_uri,
FALSE, FALSE, 0777) == GNOME_VFS_OK) {
/* found trash, put it on the list */
*result = g_list_append (*result, trash_uri);
}
gnome_vfs_uri_unref (volume_mount_point_uri);
}
/* don't stop iterating */
return FALSE;
}
GList *
nautilus_trash_monitor_get_trash_directories (void)
{
GList *result;
result = NULL;
/* Collect the trash directories on all the mounted volumes. */
nautilus_volume_monitor_each_mounted_volume
(nautilus_volume_monitor_get (), add_one_volume_trash, &result);
return result;
}
......@@ -60,7 +60,6 @@ GtkType nautilus_trash_monitor_get_type (void);
NautilusTrashMonitor *nautilus_trash_monitor_get (void);
gboolean nautilus_trash_monitor_is_empty (void);
void nautilus_trash_monitor_async_get_trash_directories (GnomeVFSAsyncFindDirectoryCallback callback,
gpointer context);
GList * nautilus_trash_monitor_get_trash_directories (void);
#endif
......@@ -318,6 +318,28 @@ nautilus_volume_monitor_volume_is_mounted (const NautilusVolume *volume)
return FALSE;
}
gboolean
nautilus_volume_monitor_should_integrate_trash (const NautilusVolume *volume)
{
/* Hand-pick a bunch of file system types that we know we can support
* trash on. It would probably be harder to keep a list of the ones
* we can't try to support trash on because the list would have to be
* more definitive.
*/
return volume->type == NAUTILUS_VOLUME_EXT2
|| volume->type == NAUTILUS_VOLUME_FAT
|| volume->type == NAUTILUS_VOLUME_NFS
|| volume->type == NAUTILUS_VOLUME_VFAT
|| volume->type == NAUTILUS_VOLUME_FLOPPY
|| volume->type == NAUTILUS_VOLUME_SMB;
}
const char *
nautilus_volume_monitor_get_volume_mount_uri (const NautilusVolume *volume)
{
return volume->mount_path;
}
static void
mount_volume_cdrom_set_state (NautilusVolumeMonitor *monitor, NautilusVolume *volume)
{
......
......@@ -111,6 +111,8 @@ gboolean nautilus_volume_monitor_is_volume_link (con
void nautilus_volume_monitor_each_volume (NautilusVolumeMonitor *monitor,
NautilusEachVolumeFunction function,
gpointer context);
gboolean nautilus_volume_monitor_should_integrate_trash (const NautilusVolume *volume);
const char *nautilus_volume_monitor_get_volume_mount_uri (const NautilusVolume *volume);
void nautilus_volume_monitor_each_mounted_volume (NautilusVolumeMonitor *monitor,
NautilusEachVolumeFunction function,
gpointer context);
......
......@@ -55,32 +55,6 @@ NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusTrashDirectory,
nautilus_trash_directory,
NAUTILUS_TYPE_MERGED_DIRECTORY)
static GnomeVFSURI *
get_volume_vfs_uri_if_writable (NautilusVolume *volume)
{
char *uri;
GnomeVFSURI *vfs_uri;
/* FIXME bugzilla.eazel.com 2443:
* Why is trash only found on EXT2 volumes? This seems
* like an incorrect check.
*/
/* FIXME bugzilla.eazel.com 2444:
* Why can't we view the trash on a read-only volume
* if it happens to be there?
*/
if (volume->type != NAUTILUS_VOLUME_EXT2 || volume->is_read_only) {
return NULL;
}
uri = gnome_vfs_get_uri_from_local_path (volume->mount_path);
vfs_uri = gnome_vfs_uri_new (uri);
g_free (uri);
return vfs_uri;
}
static void
find_directory_callback (GnomeVFSAsyncHandle *handle,
GList *results,
......@@ -129,7 +103,7 @@ add_volume (NautilusTrashDirectory *trash,
NautilusVolume *volume)
{
TrashVolume *trash_volume;
GnomeVFSURI *vfs_uri;
GnomeVFSURI *volume_mount_uri;
GList vfs_uri_as_list;
/* Quick out if we already know about this volume. */
......@@ -139,11 +113,12 @@ add_volume (NautilusTrashDirectory *trash,
return;
}
/* If we can't get the URI, we jus don't do trash on this volume. */
vfs_uri = get_volume_vfs_uri_if_writable (volume);
if (vfs_uri == NULL) {
if (!nautilus_volume_monitor_should_integrate_trash (volume)) {
return;
}
volume_mount_uri = gnome_vfs_uri_new (
nautilus_volume_monitor_get_volume_mount_uri (volume));
/* Make the structure used to track the trash for this volume. */
trash_volume = g_new0 (TrashVolume, 1);
......@@ -152,7 +127,7 @@ add_volume (NautilusTrashDirectory *trash,
g_hash_table_insert (trash->details->volumes, volume, trash_volume);
/* Find the real trash directory for this one. */
vfs_uri_as_list.data = vfs_uri;
vfs_uri_as_list.data = volume_mount_uri;
vfs_uri_as_list.next = NULL;
vfs_uri_as_list.prev = NULL;
/* Search for Trash directories but don't create new ones. */
......
......@@ -187,3 +187,57 @@ nautilus_trash_monitor_is_empty (void)
{
return nautilus_trash_monitor_get ()->details->empty;
}
static gboolean
add_one_volume_trash (const NautilusVolume *volume,
gpointer callback_data)
{
GnomeVFSURI *volume_mount_point_uri;
GnomeVFSURI *trash_uri;
GList **result;
result = (GList **)callback_data;
if (nautilus_volume_monitor_should_integrate_trash (volume)) {
/* Get the uri of the volume mount point as the place
* "near" which to look for trash on the given volume.
*/
volume_mount_point_uri = gnome_vfs_uri_new (
nautilus_volume_monitor_get_volume_mount_uri (volume));
g_assert (volume_mount_point_uri != NULL);
/* Look for trash. It is OK to use a sync call here because
* the options we use (don't create, don't look for it if we
* already don't know where it is) do not cause any IO.
*/
if (gnome_vfs_find_directory (volume_mount_point_uri,
GNOME_VFS_DIRECTORY_KIND_TRASH, &trash_uri,
FALSE, FALSE, 0777) == GNOME_VFS_OK) {
/* found trash, put it on the list */
*result = g_list_append (*result, trash_uri);
}
gnome_vfs_uri_unref (volume_mount_point_uri);
}
/* don't stop iterating */
return FALSE;
}
GList *
nautilus_trash_monitor_get_trash_directories (void)
{
GList *result;
result = NULL;
/* Collect the trash directories on all the mounted volumes. */
nautilus_volume_monitor_each_mounted_volume
(nautilus_volume_monitor_get (), add_one_volume_trash, &result);
return result;
}
......@@ -60,7 +60,6 @@ GtkType nautilus_trash_monitor_get_type (void);
NautilusTrashMonitor *nautilus_trash_monitor_get (void);
gboolean nautilus_trash_monitor_is_empty (void);
void nautilus_trash_monitor_async_get_trash_directories (GnomeVFSAsyncFindDirectoryCallback callback,
gpointer context);
GList * nautilus_trash_monitor_get_trash_directories (void);
#endif
......@@ -318,6 +318,28 @@ nautilus_volume_monitor_volume_is_mounted (const NautilusVolume *volume)
return FALSE;
}
gboolean
nautilus_volume_monitor_should_integrate_trash (const NautilusVolume *volume)
{
/* Hand-pick a bunch of file system types that we know we can support
* trash on. It would probably be harder to keep a list of the ones
* we can't try to support trash on because the list would have to be
* more definitive.
*/
return volume->type == NAUTILUS_VOLUME_EXT2
|| volume->type == NAUTILUS_VOLUME_FAT
|| volume->type == NAUTILUS_VOLUME_NFS
|| volume->type == NAUTILUS_VOLUME_VFAT
|| volume->type == NAUTILUS_VOLUME_FLOPPY
|| volume->type == NAUTILUS_VOLUME_SMB;
}
const char *
nautilus_volume_monitor_get_volume_mount_uri (const NautilusVolume *volume)
{
return volume->mount_path;
}
static void
mount_volume_cdrom_set_state (NautilusVolumeMonitor *monitor, NautilusVolume *volume)
{
......
......@@ -111,6 +111,8 @@ gboolean nautilus_volume_monitor_is_volume_link (con
void nautilus_volume_monitor_each_volume (NautilusVolumeMonitor *monitor,
NautilusEachVolumeFunction function,
gpointer context);
gboolean nautilus_volume_monitor_should_integrate_trash (const NautilusVolume *volume);
const char *nautilus_volume_monitor_get_volume_mount_uri (const NautilusVolume *volume);
void nautilus_volume_monitor_each_mounted_volume (NautilusVolumeMonitor *monitor,
NautilusEachVolumeFunction function,
gpointer context);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment