public void setProjectDescription(final Project.NameKey name, final String description) { // Update git's description file, in case gitweb is being used // try { final Repository e; final LockFile f; e = openRepository(name); try { f = new LockFile(new File(e.getDirectory(), "description"), FS.DETECTED); if (f.lock()) { String d = description; if (d != null) { d = d.trim(); if (d.length() > 0) { d += "\n"; } } else { d = ""; } f.write(Constants.encode(d)); f.commit(); } } finally { e.close(); } } catch (RepositoryNotFoundException e) { log.error("Cannot update description for " + name, e); } catch (IOException e) { log.error("Cannot update description for " + name, e); } }
private void writeFile(final File p, final byte[] bin) throws IOException, ObjectWritingException { final LockFile lck = new LockFile(p, db.getFS()); if (!lck.lock()) throw new ObjectWritingException("Can't write " + p); try { lck.write(bin); } catch (IOException ioe) { throw new ObjectWritingException("Can't write " + p); } if (!lck.commit()) throw new ObjectWritingException("Can't write " + p); }