Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Po files does not reloads when editing it with Sublime Text #494

Open
caiiiycuk opened this issue Dec 22, 2014 · 5 comments
Open

Po files does not reloads when editing it with Sublime Text #494

caiiiycuk opened this issue Dec 22, 2014 · 5 comments
Assignees

Comments

@caiiiycuk
Copy link
Contributor

Hi!

I found that po files does not reloads when I edit it with Sublime Text. It is because sublime use atomic save feature, as said here http://stackoverflow.com/a/20639093/1213348. Sublime save changes in temporary file and then replace original file with it. In this case FileMonitor.CREATE event will send not FileMonitor.MODIFY, xitrum does not handle this event for Po files. I think that this is incorrect behaviour, what do you think?

@ngocdaothanh
Copy link
Member

Nice catch! For now, please disable atomic save.

@georgeOsdDev
Copy link
Member

@caiiiycuk , @ngocdaothanh

PoLoader listens FileMonitor.MODIFY event in i18n directory.
It also contain new file creation in target directory.
In my environment(java version "1.8.0_25"),
Changing and creating new Po files with SublimeText2 and 3(Neither atomic save mode or not) trigger event.

    FileMonitor.monitor(FileMonitor.MODIFY, Paths.get("public"), { path =>
      val fileName = path.getFileName.toString
      Log.debug(fileName)
    })

This code print out both file creation and modification in public directory.

touch public/some.txt
// file creation event

echo "hello" >> public/some.txt
// file modification

@caiiiycuk
Copy link
Contributor Author

MMm...

touch public/some.txt
// file creation event

echo "hello" >> public/some.txt
// file modification

Works for me too. But saving in sublime still not works. My test case:

import xitrum.util._
import java.nio.file.Paths


object Main {
  def main(args: Array[String]) {
    FileMonitor.monitor(FileMonitor.MODIFY, Paths.get("/tmp/"), { path =>
      val fileName = path.getFileName.toString
      println("MODIFY", fileName)
    })

    FileMonitor.monitor(FileMonitor.MODIFY, Paths.get("/tmp/"), { path =>
      val fileName = path.getFileName.toString
      println("CREATE", fileName)
    })
  }
}

I open some file in sublime and then edit it. My logs:

(CREATE,.sublfe4.tmp)
(MODIFY,.sublfe4.tmp)
(CREATE,.subleb.tmp)
(MODIFY,.subleb.tmp)
(CREATE,.subl55a.tmp)
(MODIFY,.subl55a.tmp)
(CREATE,.subl88a.tmp)
(MODIFY,.subl88a.tmp)
(CREATE,.subl1db.tmp)
(MODIFY,.subl1db.tmp)
(CREATE,.subl788.tmp)
(MODIFY,.subl788.tmp)
(CREATE,sbt3496251095913698347.log)
(MODIFY,sbt3496251095913698347.log)

Looks like my sublime use move command, that does not handle at all with FileMonitor! Try this:

mv /tmp/test.tmp /tmp/test

Env:

java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.3) (7u71-2.5.3-0ubuntu0.14.04.1)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

Sublime Text 3 Build 3059

Linux caiiiycuk-desktop 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

@georgeOsdDev
Copy link
Member

I think this problem is caused by platform.
I tried run your test program and execute mv command on 2 environment.
On Mac OS X, mv event is recognized as file creation, but on CentOS, it was not recognized.

OS X Yosemite 10.10.1

OracleJDK
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b12)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
CentOS release 6.5 (Final)

OracleJDK
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

@ngocdaothanh ngocdaothanh removed this from the Xitrum 3.22 milestone Jan 13, 2015
@ngocdaothanh
Copy link
Member

Probably (and probably not) related to lloydmeta/schwatcher#49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants