public returnTypes saveChunk(BackupChunk c) {
		String recID = Packet.bytesToHex(c.getFileID());
		for(BackupChunk chunk : backedUpChunks) {
			String comID = Packet.bytesToHex(chunk.getFileID());
			if(comID.equals(recID) && chunk.getChunkNo() == c.getChunkNo()) {
				return returnTypes.FILE_EXISTS;
			}
		}
		
		if(currSize + c.getSize() > maxSize) {
			try {
				DistributedBackupSystem.tManager.executeTask(TaskManager.TaskTypes.REMOVE, null).get();
			} catch (InterruptedException e) {e.printStackTrace();} catch (ExecutionException e) {e.printStackTrace();}
			
			if(currSize + c.getSize() > maxSize)
				return returnTypes.FAILURE;
		}

		synchronized(this) {
			String name = "";
			name += "chunk-";
			name += this.nextAvailableFileNo;

			c.setFilename(name);

			File storeDir = new File("storage");
			storeDir.mkdir();

			try {
				FileOutputStream out = new FileOutputStream("storage/"+name);
				if(c.getData() != null)
					out.write(c.getData());
				out.close();
				c.eraseData();
				c.setCurrRepDeg(1);
                c.addToStored(InetAddress.getLocalHost());
				this.backedUpChunks.add(c);
				this.currSize += c.getSize();
				this.nextAvailableFileNo++;
				updateLog();

			} catch (Exception e) {
				e.printStackTrace();
				return returnTypes.FAILURE;
			}
		}

		return returnTypes.SUCCESS;
	}