gnome-split-team team mailing list archive
-
gnome-split-team team
-
Mailing list archive
-
Message #00062
[Branch ~respawneral/gnome-split/mainline] Rev 233: Handle cases where a chunk is missing.
------------------------------------------------------------
revno: 233
committer: Guillaume Mazoyer <respawneral@xxxxxxxxx>
branch nick: gnome-split
timestamp: Tue 2010-10-12 16:38:32 +0200
message:
Handle cases where a chunk is missing.
Instead of throwing a common 'file not found
exception', we now use our own exception to
inform the user that a chunk is missing. The
is stopped and we ask the user to check if all
the chunks are in the same directory.
added:
src/org/gnome/split/core/exception/MissingChunkException.java
modified:
src/org/gnome/split/core/exception/ExceptionMessage.java
src/org/gnome/split/core/merger/Generic.java
src/org/gnome/split/core/merger/GnomeSplit.java
src/org/gnome/split/core/merger/KFK.java
src/org/gnome/split/core/merger/Xtremsplit.java
src/org/gnome/split/core/merger/YoyoCut.java
src/org/gnome/split/gtk/DefaultEngineListener.java
--
lp:gnome-split
https://code.launchpad.net/~respawneral/gnome-split/mainline
Your team GNOME Split developers is subscribed to branch lp:gnome-split.
To unsubscribe from this branch go to https://code.launchpad.net/~respawneral/gnome-split/mainline/+edit-subscription
=== modified file 'src/org/gnome/split/core/exception/ExceptionMessage.java'
--- src/org/gnome/split/core/exception/ExceptionMessage.java 2010-06-19 14:54:44 +0000
+++ src/org/gnome/split/core/exception/ExceptionMessage.java 2010-10-12 14:38:32 +0000
@@ -33,7 +33,9 @@
_("MD5 sums are different."),
_("There is no guarantee that the created file will work. Maybe you should try to merge the chunks again.")), INVALID_SIZE(
_("Invalid chunk size."),
- _("You must specify a size which is lower than the size of the file to split."));
+ _("You must specify a size which is lower than the size of the file to split.")), MISSING_CHUNK(
+ _("Missing chunk."),
+ _("A chunk appears to be missing. Please check that all chunks are in the same directory."));
/**
* The message which will be used in the {@link Exception}.
=== added file 'src/org/gnome/split/core/exception/MissingChunkException.java'
--- src/org/gnome/split/core/exception/MissingChunkException.java 1970-01-01 00:00:00 +0000
+++ src/org/gnome/split/core/exception/MissingChunkException.java 2010-10-12 14:38:32 +0000
@@ -0,0 +1,38 @@
+/*
+ * MissingChunkException.java
+ *
+ * Copyright (c) 2009-2010 Guillaume Mazoyer
+ *
+ * This file is part of GNOME Split.
+ *
+ * GNOME Split is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GNOME Split is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNOME Split. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.gnome.split.core.exception;
+
+/**
+ * Define a new {@link Exception} to manage exceptions due to a missing chunk.
+ *
+ * @author Guillaume Mazoyer
+ */
+public final class MissingChunkException extends EngineException
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Create an {@link Exception} with an {@link ExceptionMessage} .
+ */
+ public MissingChunkException() {
+ super(ExceptionMessage.MISSING_CHUNK);
+ }
+}
=== modified file 'src/org/gnome/split/core/merger/Generic.java'
--- src/org/gnome/split/core/merger/Generic.java 2010-04-12 23:30:29 +0000
+++ src/org/gnome/split/core/merger/Generic.java 2010-10-12 14:38:32 +0000
@@ -26,6 +26,7 @@
import java.io.RandomAccessFile;
import org.gnome.split.GnomeSplit;
+import org.gnome.split.core.exception.MissingChunkException;
/**
* Algorithm to merge files with an algorithm which does not use any headers
@@ -106,8 +107,15 @@
parts = file.getName().endsWith(".000") ? 0 : 1;
for (int i = parts; i <= parts; i++) {
- // Open the current part to merge
+ // Next chunk
chunk = new File(this.getNextChunk(part, i));
+ if (!chunk.exists()) {
+ // Check if the chunk really exists
+ this.fireEngineError(new MissingChunkException());
+ return;
+ }
+
+ // Open the chunk to read it
RandomAccessFile access = new RandomAccessFile(chunk, "r");
// Notify the view from a new part read
=== modified file 'src/org/gnome/split/core/merger/GnomeSplit.java'
--- src/org/gnome/split/core/merger/GnomeSplit.java 2010-04-14 15:36:46 +0000
+++ src/org/gnome/split/core/merger/GnomeSplit.java 2010-10-12 14:38:32 +0000
@@ -25,8 +25,8 @@
import java.io.IOException;
import java.io.RandomAccessFile;
-import org.gnome.split.core.exception.EngineException;
import org.gnome.split.core.exception.MD5Exception;
+import org.gnome.split.core.exception.MissingChunkException;
import org.gnome.split.core.utils.MD5Hasher;
/**
@@ -111,8 +111,15 @@
byte[] buffer;
for (int i = 1; i <= parts; i++) {
- // Open the current part to merge
+ // Next chunk
chunk = new File(this.getNextChunk(part, i));
+ if (!chunk.exists()) {
+ // Check if the chunk really exists
+ this.fireEngineError(new MissingChunkException());
+ return;
+ }
+
+ // Open the chunk to read it
RandomAccessFile access = new RandomAccessFile(chunk, "r");
// Notify the view from a new part read
@@ -166,8 +173,7 @@
if (!success && md5) {
// Notify the error
- EngineException exception = new MD5Exception();
- this.fireEngineError(exception);
+ this.fireEngineError(new MD5Exception());
} else if (success) {
if (app.getConfig().DELETE_PARTS && md5) {
// Delete all parts if and *only if* the MD5 sums are
=== modified file 'src/org/gnome/split/core/merger/KFK.java'
--- src/org/gnome/split/core/merger/KFK.java 2010-04-12 23:30:29 +0000
+++ src/org/gnome/split/core/merger/KFK.java 2010-10-12 14:38:32 +0000
@@ -26,6 +26,7 @@
import java.io.RandomAccessFile;
import org.gnome.split.GnomeSplit;
+import org.gnome.split.core.exception.MissingChunkException;
/**
* Algorithm to merge files with the KFK algorithm.
@@ -84,8 +85,15 @@
out = new RandomAccessFile(filename, "rw");
for (int i = 0; i < parts; i++) {
- // Open the current part to merge
+ // Next chunk
chunk = new File(this.getNextChunk(part, i));
+ if (!chunk.exists()) {
+ // Check if the chunk really exists
+ this.fireEngineError(new MissingChunkException());
+ return;
+ }
+
+ // Open the chunk to read it
RandomAccessFile access = new RandomAccessFile(chunk, "r");
// Notify the view from a new part read
=== modified file 'src/org/gnome/split/core/merger/Xtremsplit.java'
--- src/org/gnome/split/core/merger/Xtremsplit.java 2010-08-23 22:40:44 +0000
+++ src/org/gnome/split/core/merger/Xtremsplit.java 2010-10-12 14:38:32 +0000
@@ -26,8 +26,8 @@
import java.io.RandomAccessFile;
import org.gnome.split.GnomeSplit;
-import org.gnome.split.core.exception.EngineException;
import org.gnome.split.core.exception.MD5Exception;
+import org.gnome.split.core.exception.MissingChunkException;
import org.gnome.split.core.utils.ByteUtils;
import org.gnome.split.core.utils.MD5Hasher;
@@ -162,8 +162,15 @@
}
for (int i = 1; i <= parts; i++) {
- // Open the current part to merge
+ // Next chunk
chunk = new File(this.getNextChunk(part, i));
+ if (!chunk.exists()) {
+ // Check if the chunk really exists
+ this.fireEngineError(new MissingChunkException());
+ return;
+ }
+
+ // Open the chunk to read it
RandomAccessFile access = new RandomAccessFile(chunk, "r");
// Notify the view from a new part read
@@ -232,8 +239,7 @@
if (!success && md5) {
// Notify the error
- EngineException exception = new MD5Exception();
- this.fireEngineError(exception);
+ this.fireEngineError(new MD5Exception());
} else if (success) {
if (app.getConfig().DELETE_PARTS && md5) {
// Delete all parts if and *only if* the MD5 sums are
=== modified file 'src/org/gnome/split/core/merger/YoyoCut.java'
--- src/org/gnome/split/core/merger/YoyoCut.java 2010-04-14 15:36:46 +0000
+++ src/org/gnome/split/core/merger/YoyoCut.java 2010-10-12 14:38:32 +0000
@@ -27,8 +27,8 @@
import java.util.ArrayList;
import org.gnome.split.GnomeSplit;
-import org.gnome.split.core.exception.EngineException;
import org.gnome.split.core.exception.MD5Exception;
+import org.gnome.split.core.exception.MissingChunkException;
import org.gnome.split.core.utils.MD5Hasher;
/**
@@ -157,8 +157,15 @@
out = new RandomAccessFile(filename, "rw");
for (int i = 1; i <= parts; i++) {
- // Open the current part to merge
+ // Next chunk
chunk = new File(this.getNextChunk(part, i));
+ if (!chunk.exists()) {
+ // Check if the chunk really exists
+ this.fireEngineError(new MissingChunkException());
+ return;
+ }
+
+ // Open the chunk to read it
RandomAccessFile access = new RandomAccessFile(chunk, "r");
// Notify the view from a new part read
@@ -204,8 +211,7 @@
if (!success && md5) {
// Notify the error
- EngineException exception = new MD5Exception();
- this.fireEngineError(exception);
+ this.fireEngineError(new MD5Exception());
} else if (success) {
if (app.getConfig().DELETE_PARTS && md5) {
// Delete all parts if and *only if* the MD5 sums are
=== modified file 'src/org/gnome/split/gtk/DefaultEngineListener.java'
--- src/org/gnome/split/gtk/DefaultEngineListener.java 2010-09-08 22:17:00 +0000
+++ src/org/gnome/split/gtk/DefaultEngineListener.java 2010-10-12 14:38:32 +0000
@@ -34,6 +34,7 @@
import org.gnome.split.core.exception.EngineException;
import org.gnome.split.core.exception.ExceptionMessage;
import org.gnome.split.core.exception.InvalidSizeException;
+import org.gnome.split.core.exception.MissingChunkException;
import org.gnome.split.core.splitter.DefaultSplitEngine;
import org.gnome.split.core.utils.SizeUnit;
import org.gnome.split.dbus.DbusInhibit;
@@ -307,14 +308,15 @@
message = exception.getExceptionMessage();
gtk.getInfoBar().showWarning(message.getMessage(), message.getDetails());
} else {
- // First print the stacktrace
- exception.printStackTrace();
-
- if (exception instanceof InvalidSizeException) {
+ if ((exception instanceof InvalidSizeException)
+ || (exception instanceof MissingChunkException)) {
// Invalid size exception
message = exception.getExceptionMessage();
dialog = new ErrorDialog(gtk, message.getMessage(), message.getDetails());
} else {
+ // First print the stacktrace
+ exception.printStackTrace();
+
// Other exception - error (file is supposed broken)
dialog = new ErrorDialog(
gtk,