File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
biojava-structure/src/main/java/org/biojava/nbio/structure/io Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,9 @@ public static enum FetchBehavior {
127127
128128 protected static final String lineSplit = System .getProperty ("file.separator" );
129129
130+ /** Minimum size for a valid file, in bytes */
131+ public static final long MIN_PDB_FILE_SIZE = 40 ;
132+
130133 private File path ;
131134 private List <String > extensions ;
132135
@@ -687,6 +690,14 @@ public File getLocalFile(String pdbId) {
687690 for (String ex : getExtensions () ){
688691 File f = new File (searchdir ,prefix + pdbId .toLowerCase () + ex ) ;
689692 if ( f .exists ()) {
693+ // delete files that are too short to have contents
694+ if ( f .length () < MIN_PDB_FILE_SIZE ) {
695+ boolean success = f .delete ();
696+ if ( ! success ) {
697+ return null ;
698+ }
699+ assert (!f .exists ());
700+ }
690701 return f ;
691702 }
692703 }
Original file line number Diff line number Diff line change 4242import org .biojava .nbio .core .util .InputStreamProvider ;
4343import org .biojava .nbio .structure .align .util .HTTPConnectionTools ;
4444import org .biojava .nbio .structure .align .util .UserConfiguration ;
45+ import org .biojava .nbio .structure .io .LocalPDBDirectory ;
4546import org .biojava .nbio .structure .io .mmcif .model .ChemComp ;
4647import org .slf4j .Logger ;
4748import org .slf4j .LoggerFactory ;
@@ -344,6 +345,12 @@ private static boolean fileExists(String recordName){
344345
345346 File f = new File (fileName );
346347
348+ // delete files that are too short to have contents
349+ if ( f .length () < LocalPDBDirectory .MIN_PDB_FILE_SIZE ) {
350+ f .delete ();
351+ return false ;
352+ }
353+
347354 return f .exists ();
348355
349356 }
You can’t perform that action at this time.
0 commit comments