Changeset 4c18e2f for core


Ignore:
Timestamp:
Dec 8, 2017 4:08:17 PM (3 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
5aef5e2
Parents:
a3e42c43
Message:

SU3File: Flush and sync on extract (ticket #1941)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/crypto/SU3File.java

    ra3e42c43 r4c18e2f  
    387387    public boolean verifyAndMigrate(File migrateTo) throws IOException {
    388388        InputStream in = null;
    389         OutputStream out = null;
     389        FileOutputStream out = null;
    390390        boolean rv = false;
    391391        try {
     
    422422            }
    423423            if (migrateTo != null)  // else verify only
    424                 out = new FileOutputStream(migrateTo);
     424                out = new SecureFileOutputStream(migrateTo);
    425425            byte[] buf = new byte[16*1024];
    426426            long tot = 0;
     
    455455        } finally {
    456456            if (in != null) try { in.close(); } catch (IOException ioe) {}
    457             if (out != null) try { out.close(); } catch (IOException ioe) {}
     457            if (out != null) {
     458                // We will generally be reading this file right back in,
     459                // so do a POSIX flush and sync to ensure it will be there.
     460                try {
     461                    out.flush();
     462                    out.getFD().sync();
     463                } catch (IOException ioe) {}
     464                try { out.close(); } catch (IOException ioe) {}
     465            }
    458466            if (migrateTo != null && !rv)
    459467                migrateTo.delete();
Note: See TracChangeset for help on using the changeset viewer.