MCPcopy Create free account
hub / github.com/annmuor/jnode / hatchFile

Method hatchFile

jnode-core/src/jnode/ftn/FtnTools.java:1594–1626  ·  view source on GitHub ↗

Отправка файла в фэху @param area @param attach @param description

(Filearea area, File attach, String filename,
			String description)

Source from the content-addressed store, hash-verified

1592 * @param description
1593 */
1594 public static void hatchFile(Filearea area, File attach, String filename,
1595 String description) {
1596 Filemail mail = new Filemail();
1597 mail.setFilearea(area);
1598 mail.setFiledesc(description);
1599 mail.setFilename(filename);
1600 mail.setCreated(new Date());
1601 mail.setOrigin(getPrimaryFtnAddress().toString());
1602 mail.setPath("PATH " + getPrimaryFtnAddress().toString() + " "
1603 + (mail.getCreated().getTime() / 1000) + " "
1604 + mail.getCreated().toString() + "\r\n");
1605 mail.setSeenby("");
1606 String path = getFilePath(area.getName(), filename);
1607 File newFile = new File(path);
1608 if (FileUtils.move(attach, newFile, true)) {
1609 mail.setFilepath(newFile.getAbsolutePath());
1610 } else {
1611 mail.setFilepath(attach.getAbsolutePath());
1612 logger.l2("Failed to rename " + attach.getAbsolutePath() + " to "
1613 + path);
1614 }
1615 ORMManager.get(Filemail.class).save(mail);
1616
1617 for (FileSubscription sub : ORMManager.get(FileSubscription.class)
1618 .getAnd("filearea_id", "=", area)) {
1619 ORMManager.get(FilemailAwaiting.class).save(
1620 new FilemailAwaiting(sub.getLink(), mail));
1621 if (getOptionBooleanDefFalse(sub.getLink(),
1622 LinkOption.BOOLEAN_CRASH_FILEMAIL)) {
1623 PollQueue.getSelf().add(sub.getLink());
1624 }
1625 }
1626 }
1627
1628 public static String getFilePath(String area, String attach) {
1629 String areaPath = FtnTosser.getFileechoPath() + File.separator + area;

Callers 1

hatchToAreaMethod · 0.95

Calls 15

setFileareaMethod · 0.95
setFiledescMethod · 0.95
setFilenameMethod · 0.95
setCreatedMethod · 0.95
setOriginMethod · 0.95
getPrimaryFtnAddressMethod · 0.95
setPathMethod · 0.95
getCreatedMethod · 0.95
setSeenbyMethod · 0.95
getFilePathMethod · 0.95
moveMethod · 0.95
setFilepathMethod · 0.95

Tested by

no test coverage detected