Apply les trucs de l'exception
This commit is contained in:
		@ -41,3 +41,4 @@ tasks.register("run") {
 | 
			
		||||
tasks.withType<Test> {
 | 
			
		||||
	useJUnitPlatform()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,4 +0,0 @@
 | 
			
		||||
package ovh.herisson.Clyde.Exceptions;
 | 
			
		||||
 | 
			
		||||
public class CouldntDeleteFileException extends Exception{
 | 
			
		||||
}
 | 
			
		||||
@ -1,15 +1,12 @@
 | 
			
		||||
package ovh.herisson.Clyde.Services;
 | 
			
		||||
 | 
			
		||||
import org.springframework.core.io.UrlResource;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.web.multipart.MultipartFile;
 | 
			
		||||
import ovh.herisson.Clyde.Exceptions.CouldntDeleteFileException;
 | 
			
		||||
import ovh.herisson.Clyde.Repositories.FileRepository;
 | 
			
		||||
import ovh.herisson.Clyde.Tables.*;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
 | 
			
		||||
import java.nio.file.Files;
 | 
			
		||||
import java.nio.file.Path;
 | 
			
		||||
@ -57,13 +54,13 @@ public class StorageService {
 | 
			
		||||
        return url;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void delete(StorageFile file) throws CouldntDeleteFileException {
 | 
			
		||||
    public void delete(StorageFile file) throws SecurityException {
 | 
			
		||||
        File f = new File(file.getUrl());
 | 
			
		||||
        //Delete le fichier
 | 
			
		||||
        try{
 | 
			
		||||
            f.delete();
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new CouldntDeleteFileException();
 | 
			
		||||
            throw new SecurityException();
 | 
			
		||||
        }
 | 
			
		||||
        //Delete l'entité
 | 
			
		||||
        fileRepo.delete(file);
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user